Converting number to string in a cell data ?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Ugurcan Ozdemir
le 10 Sep 2014
Modifié(e) : Ugurcan Ozdemir
le 10 Sep 2014
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
0 commentaires
Réponse acceptée
Image Analyst
le 10 Sep 2014
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 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!