using for command to get multiple string values

Hi, help me about my problem
I need to get multiple string values from the user and then I want to store all the variables that user entered. After that I want to display them whenever I want
I just wrote some code with using for loop but the problem I can not make the variable store all the strings that I entered.
for i=1:5
names=input('Enter your name: ' , 's');
name_lists{i}=names;
end
c=name_lists{i};
fprintf( '%s\n', c);
at the end of the code I want to display all the variables that I entered

回答 (1 件)

darova
darova 2020 年 4 月 10 日

0 投票

Try this
fprintf('%s\n', name_lists{:});

1 件のコメント

Std1
Std1 2020 年 4 月 10 日
Thank you very much, ıt worked

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2020 年 4 月 10 日

コメント済み:

2020 年 4 月 10 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by