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!