How to plot multiple iterations on the same axes?

조회 수: 15 (최근 30일)
Priya
Priya 2014년 5월 27일
편집: Mahdi 2014년 5월 27일
Hi,
I'm trying to plot the below.
In x-axis, I have
s_x_index=[0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10]
In y-axis, I have a signal f_x, whose value keeps on changing for each iteration. Now I need to plot in such a way that, s_x_index takes the current f_x value and the other curve in the plot should result from s_x_index taking the next value of f_x obtained during the next iteration.
Please do help.

답변 (2개)

rifat
rifat 2014년 5월 27일
first, write
figure; hold on;
then use a loop. witing each iteration plot your curve.
plot(s_x_index,f_x)
  댓글 수: 1
Priya
Priya 2014년 5월 27일
편집: Priya 2014년 5월 27일
Thanks. Could you please elaborate and tell me how to use the loop.

댓글을 달려면 로그인하십시오.


Mahdi
Mahdi 2014년 5월 27일
figure; hold on
for i=1:length(s_x_index)
f_value(i)=f_x # This is the value that you get from each iteration
end
plot(s_x_index,f_value)
  댓글 수: 2
Priya
Priya 2014년 5월 27일
편집: Priya 2014년 5월 27일
Thank you. But my f_x generates a different value for each iteration. I'm trying to show all the points of f_x for each s_x_index in the same plot.
Mahdi
Mahdi 2014년 5월 27일
편집: Mahdi 2014년 5월 27일
So, inside your loop, you can simply do the following
figure; hold on
#Start your loop, at the end of it
plot(s_x_index, f_x)
#End your loop
as suggested in the other answer.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by