How to plot data inside a for loop?

I would like to know how to plot a graph in a GUI like a scope or moving graph as the data point is simulated inside a for loop. and also how to move x-axis which is time in my problem along with the graph. For example how to plot a moving sin wave with respect to time.

답변 (1개)

Wayne King
Wayne King 2012년 5월 5일

0 개 추천

A simple way:
n = 0:199;
for nn = 1:length(n)
plot(cos(pi/4*(n(1:nn))));
axis([1 100 -1 1]);
pause(0.2);
hold on;
end

댓글 수: 3

Sampath reddy
Sampath reddy 2012년 5월 5일
First: i dont want to use plot every time. I'm thinking of more like updating.
Second: The graphs is not moving to left after the data points crossed 100
Jan
Jan 2012년 5월 5일
Wayne's example contains all commands, which are necessary to solve your demands. Did you try to modify it?
Sampath reddy
Sampath reddy 2012년 5월 6일
yes!! i got it!

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

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2012년 5월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by