How to store user-generated text within a loop?
古いコメントを表示
How would i write this code to run in a loop?
p='What is the name of a eng 1315 student? ';
n1=input(p,'s');
n2=input(p,'s');
n3=input(p,'s');
n4=input(p,'s');
n5=input(p,'s');
my objective involves importing data (which will be set of grades) from an excel doc then sorting and calculating the data for the entered students to be displayed in order from highest average to lowest. I would like to shorten this portion because extra credit will be given to the student with the shortest code. If running this in a loop is not possible I am open for any other suggestions to shorten this portion. Thanks.
採用された回答
その他の回答 (1 件)
Guillaume
2014 年 11 月 13 日
Inside the loop store the result of input in a matrix, using the loop index as the matrix index.
n(i) = input(p, 's');
2 件のコメント
Guillaume
2014 年 11 月 13 日
Yes, indeed. Don't know why I was thinking Caleb was storing numbers.
As Evan says, use a cell array instead of a matrix.
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!