Write a script that will keep prompting the user for a string then stores them in a cell array and prints to display all strings in this cell array:
1 回表示 (過去 30 日間)
古いコメントを表示
string=input('PLEASE INPUT A STRING:','s');
string1={i}
I believe I would need a for loop and to use celldisp but I am having trouble figuring out how to do those.
0 件のコメント
採用された回答
Image Analyst
2013 年 10 月 20 日
編集済み: Image Analyst
2013 年 10 月 20 日
Try this:
maxCount = 10; % a "Failsafe"
counter = 1; % Failsafe.
while counter <= maxCount
string = input('PLEASE INPUT A STRING (Type quit to exit):', 's');
if ~isempty(strfind(lower(string), 'quit'))
break;
end
strings{counter} = string
counter = counter + 1;
end
fprintf('Done!\n');
celldisp(strings);
2 件のコメント
Image Analyst
2013 年 10 月 20 日
編集済み: Image Analyst
2013 年 10 月 20 日
Please mask the answer as accepted and let people know in your other duplicate question that you have a solution. In your duplicate question you said you want to call celldisp() so I added that at the end of the code, though it was already displaying it inside the loop because I left off the semicolon on the assignment line.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!