フィルターのクリア

How do I turn a number array into a specific string set?

1 回表示 (過去 30 日間)
Hannah
Hannah 2013 年 5 月 16 日
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

採用された回答

SL B
SL B 2013 年 5 月 16 日
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
  1 件のコメント
Hannah
Hannah 2013 年 5 月 16 日
Thank you so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by