How to initialize number of iteration?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello!
i ran my program code for 100 iterations in order to check result as function of variable A using this command :
A_100_iteration=[];
Result_100_iteration =[];
for n=1:100
%my program
A_100_iteration=[A_100_iteration,A] ; %first variable
Result_100_iteration=[Result_100_iteration,Result] ; %
end
Now i have t to change a new variable in my program denoted "B" whish is a vector [1*3600] ,but just the first element B(1) which is varied from [0 to 1000] as follow [0,20,40,60,80,100,..].
the first element B(1) is already initialized in my code, but i'm asking if it is possible to do a loop for in order to change each time.
for example ,
do 100 iteration,
B(1)=0,
do 100 iteration,
B(1)=20,
do 100 iteration,
B(1)=40
...
i'm looking for an easy method to just display the 100 iterations for each new value of B(1).
I hope that all is clear,
Thanks in advance
0 件のコメント
採用された回答
Torsten
2022 年 12 月 2 日
A_100_iteration = cell(51,1);
Result_100_iteration = cell(51,1);
for ib = 1:51
B(1) = (ib-1)*20;
for n = 1:100
%my program,e.g.
A = 1;
Result = 1;
A_100_iteration{ib}=[A_100_iteration{ib},A] ; %first variable
Result_100_iteration{ib}=[Result_100_iteration{ib},Result] ; %
end
end
A_100_iteration{3}
Result_100_iteration{3}
7 件のコメント
Torsten
2022 年 12 月 2 日
I know too little about the underlying problem and the way you try to solve it to answer your question.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!