using for command to get multiple string values

3 views (last 30 days)
Std1
Std1 on 10 Apr 2020
Commented: Std1 on 10 Apr 2020
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

Answers (1)

darova
darova on 10 Apr 2020
Try this
fprintf('%s\n', name_lists{:});

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!