How to plot data inside a for loop?

1 Ansicht (letzte 30 Tage)
Sampath reddy
Sampath reddy am 5 Mai 2012
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.

Antworten (1)

Wayne King
Wayne King am 5 Mai 2012
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 Kommentare
Jan
Jan am 5 Mai 2012
Wayne's example contains all commands, which are necessary to solve your demands. Did you try to modify it?
Sampath reddy
Sampath reddy am 6 Mai 2012
yes!! i got it!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu View and Analyze Simulation Results finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by