Plotting curve for the values of for loop
1 回表示 (過去 30 日間)
古いコメントを表示
I've written a script that uses a for loop to calculate a specific value. After each loop iteration, the value of the variable is updated. How can I save the variable's value in an array so that I can use it to plot a curve later?
Thanks in advance.
For example,
N = 1:1:5
for i=1:length(N)
Performs calculation
S = output
end
I need to plot (N,S)
Sample test code is attached.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1098270/image.jpeg)
0 件のコメント
回答 (1 件)
Walter Roberson
2022 年 8 月 15 日
N = 1:1:5
for i=1:length(N)
Performs calculation
S(:,i) = output(:);
end
This will create one column for each entry in N.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!