plot data into a while lopp without storing the data
4 views (last 30 days)
Show older comments
Hello,
I have a while loop that iterates 2500 times and in each loop I get 3 arrays of 6x1. I dont want to store the data for each iteration, only plot the actual data and keep updating the same plot... is that possible??
Thanks in advance
2 Comments
Accepted Answer
Voss
on 20 Jan 2022
If you want each new iteration to replace previously plotted results:
i = 0
while i < 2500
% do stuff
hold off
plot(x)
hold on
plot(y)
plot(z)
drawnow()
i = i+1;
end
If you want each new iteration to add to the previously plotted results:
hold on
i = 0
while i < 2500
% do stuff
plot(x)
plot(y)
plot(z)
drawnow()
i = i+1;
end
3 Comments
Voss
on 21 Jan 2022
The line:
plot(i,qs(1,1))
plots one point. What happens if you replace that with this:
plot(qs(:,1))
or perhaps this:
plot(i*ones(n,1),qs(:,1))
Try those and see if it's more like what you want.
(And if you attach the necessary mat files, I'll be able to run the code and provide more useful help.)
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!