Modifying this code to make a cell array?
1 回表示 (過去 30 日間)
古いコメントを表示
Andrew Ardolino
2014 年 11 月 20 日
コメント済み: Andrew Ardolino
2014 年 11 月 20 日
sizegroup=input('Enter number of students: ');
for k = 1:1:sizegroup
%read in name and score
name=input('enter name: ', 's');
score = input ('enter score: ');
%disp name and score
disp('Name and score are');
disp(name)
disp(score)
names=[]
end
Hi, I need to modify this code to make it create a cell array of student data (names and scores) and then display it, and i'm not sure about how to go about doing this without it replacing the values within each loop?
Thanks in advance
0 件のコメント
採用された回答
Andrew Reibold
2014 年 11 月 20 日
編集済み: Andrew Reibold
2014 年 11 月 20 日
sizegroup=input('Enter number of students: ');
for k = 1:sizegroup
name=input('enter name: ', 's'); %read in name and score
score = input ('enter score: ');
name_score{k,1} = name; %save to cell array
name_score{k,2} = score;
end
disp(name_score)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!