how to make the output change in a loop

%greetings
%im doing a code to add an unlimted team names
%my isseue is i don't know how to make the output change every time the loop is runinng
disp("how many teams ")
v=input('Num: ')
n=1
for a=1:v
t = strcat( 'variable_',num2str(v) )
variable.(t) = v
if n>0
n=1
n=input('team Name: ','s')
else
disp("alright")
end
end

1 Comment

You're probably going to want to use the variable 'a' somewhere in your for loop, since that is the loop iteration variable.

Sign in to comment.

 Accepted Answer

Are you expecting something like this?
disp("how many teams ")
n=input('Num: ') ;
S = struct ;
for i=1:n
S(i).Team = input('team Name: ','s') ;
end
S

3 Comments

great
but i need it to have it's own variable
so later i can add the marks for each team
Okay you can add...follow the same like shown, open a different field.
S(i).Marks = 34 ;

Sign in to comment.

More Answers (0)

Categories

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

Community Treasure Hunt

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

Start Hunting!