필터 지우기
필터 지우기

Plotting curve for the values of for loop

조회 수: 1 (최근 30일)
Chinmayraj Doddarajappa
Chinmayraj Doddarajappa 2022년 8월 15일
답변: Walter Roberson 2022년 8월 15일
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.

답변 (1개)

Walter Roberson
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.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by