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
2012-5-5
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
2012-5-5
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
2012-5-6
类别
在 帮助中心 和 File 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!