I am doing something like this:
a = [1:100];
for i=1:100,
plot([1:i], a(1:i));
end
My issue is that the plot is not shown until the loop is finished. How can I show/update the plot in every iteration?
Update Plot Using Data LinkingCreate the variable x to represent the iteration number and y to represent the approximation. Plot the initial values of x and y . Turn on data linking using linkdata on so that the plot updates when the variables change. Then, update x and y in a for loop.
Use DRAWNOW
a = [1:100];
for i=1:100,
plot([1:i], a(1:i));
drawnow
end
Alternatively, you may want to have a look at ANYMATE from the file exchange.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With