How do I turn a number array into a specific string set?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Akzeptierte Antwort
SL B
am 16 Mai 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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Cell Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!