How to join text in a table cell?
Show older comments
Dear All,
This seems very simple but it is puzzling me.
I have a table that is called..well Table, I have attached a screenshot of it. The table is (69 by 5), I added an empty column called "Warning" to let me know if if any of the years exceed a specific threshold and if they do in which category of the letters.
So here is what I did:
Matrix = table2array(Table); % converted my Table into an array, Matrix is 69 by 4
v= {[],[],'M', 'X', 'N'};
%Adding the column of warning
emptyCol = cell(length(Years),1);
Table = [ table(emptyCol,'VariableNames', {'Warning'}) Table];
% Setting the threshold, if any values in columns M, X and N exceed 100, then the Warning column contains the letter
for i = 2:5
for d = 1:length(Years)
if ((Matrix(d,i))> 100 == 1);
Table.Warning(d)= v(i+1);
end
end
end
My problem is that if I run the code with values that exceed the threshold in columns M, X and N, I only get for N. what I mean is that the letters get over written I cant seem to have all three together like 'M','N','X' instead of just N. I tried to use strcat but nothing happens, it's either I am using it wrong or it's not what I should use for this case.
If you have any ideas on how I can overcome this please let me know.
Thank you,
M
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!