Converting number to string in a cell data ?

6 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by