how to make the output change in a loop

3 ビュー (過去 30 日間)
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 1 月 27 日
コメント済み: Faisal Al-Wazir 2022 年 1 月 28 日
%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 件のコメント
Voss
Voss 2022 年 1 月 27 日
You're probably going to want to use the variable 'a' somewhere in your for loop, since that is the loop iteration variable.

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

採用された回答

KSSV
KSSV 2022 年 1 月 28 日
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 件のコメント
KSSV
KSSV 2022 年 1 月 28 日
Okay you can add...follow the same like shown, open a different field.
S(i).Marks = 34 ;
Faisal Al-Wazir
Faisal Al-Wazir 2022 年 1 月 28 日
thank you

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by