How do I turn a number array into a specific string set?
9 views (last 30 days)
Show older comments
Hi,
I have an array of data (numbers) (set of 24) that I would like to turn into a string array and then add to a cell array (with a specified row) so it can be put into a GUI table. colorgen gives each specific cell a color background (given by the code http://www.mathworks.com/matlabcentral/answers/25038-how-to-change-each-cell-color-in-a-uitable). In order for this code to work the number data has to be a string. So for example, one element of the original array could be 722.845, which i would like to turn into '722.845', and then place into position data{3, 2}. But when I use the for loop, and get the numel (or size) or array_cell i get the number of characters in the array which is about ~300, and not 24 (which how many elements are in the original array) and the table prints out each character into one box. Help!
array_cell = num2str(array);
for i=1:numel(array_cell) %size(array_cell,2)
data{row,i+1} = colorgen(color, array_cell(i));
end
0 Comments
Accepted Answer
SL B
on 16 May 2013
array_cell = num2str(array) I think is the problem. Try using the num2str within the for loop.
for i=1:size(array,2)
data{row,i+1} = colorgen(color, num2str(array(i)));
end
More Answers (0)
See Also
Categories
Find more on Cell Arrays 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!