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 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