Converting number to string in a cell data ?

6 ビュー (過去 30 日間)
Ugurcan Ozdemir
Ugurcan Ozdemir 2014 年 9 月 10 日
編集済み: Ugurcan Ozdemir 2014 年 9 月 10 日
I have a code like that:
data={'class' 'note 1' 'note 2' 'note 3' 'note 4' 'note 5' ;...
'math' 50 45 68 75 64; ...
'physics ' 67 54 67 89 90; ...
'chemistry' 45 76 23 76 89;
'physics ' 32 45 65 76 93;
'math' 54 76 34 54 56};
[row_data column_data] = size(data);
math_finder = 'math';
row_finder = strfind(data, math_finder);
row_number = find(~cellfun('isempty',strfind(data,'math')));
for i = 1:length(row_number)
classmath_note1(i)=data(row_number(i),2);
classmath_note2(i)=data(row_number(i),3);
classmath_note3(i)=data(row_number(i),4);
classmath_note4(i)=data(row_number(i),5);
classmath_note5(i)=data(row_number(i),6);
end
I want to classify math class notes. I mean, at the end, work space should be like that:
Name - Value
classmath_note1 = [50 54]
classmath_note2 = [45 76]
classmath_note3 = [68 34]
classmath_note4 = [75 54]
classmath_note5 = [64 56]
However, I receive this error:
If any of the input arguments are cell arrays, the first must be a cell array of strings and the second must be a character array.
How can I solve this problem ?
Thank you in advance

採用された回答

Image Analyst
Image Analyst 2014 年 9 月 10 日
Use a table. It would be so much easier than a cell array. http://www.mathworks.com/help/matlab/ref/table.html Let us know if you can't figure it out.
  1 件のコメント
Ugurcan Ozdemir
Ugurcan Ozdemir 2014 年 9 月 10 日
編集済み: Ugurcan Ozdemir 2014 年 9 月 10 日
Actually, the issue is that I read the data from xlsx. file, I do not create the data. And when i read the data from excel, I have a data like that.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by