Plotting datapoint as you calculate them
Afficher commentaires plus anciens
I realise that it's easy enough to plot a simple graph of x and y data which have already been calculated in an array, eg :
x=-1:0.01:1;
y=sqrt(1-(x.^2));
plot(x,y)
will give me a chart of my simple curve.
However, if I change the increment from 0.01 to 1E-7 the calculations are fast enough but the plot takes quite a while to appear.
I'd like to plot the x,y position data as they're calculated rather than waiting until the end of all the calculations.
I tried this :
x=-1;
while(x<1)
y=sqrt(1-(x^2));
plot(x,y)
hold on
x=x+0.01
end
%note each iteration's datapoints (x&y) are deliberating not stored in an array as I won't need them.
but it only plots my last point rather than plotting all the points on the curve as it calculated them.
I'm guessing that Matlab only undertakes a plot once calculation loops are completed (?).
It might be that I'm being dumb or maybe that plotting a curve point by point as they are calculated just isn't supported?
I realise I can just use the first method, keep all my data pairs and plot at the end of all calculations. This will, in practice, probably result in me spending a lot of cumulative unnecessary time sitting in front of my computer!
Can anyone offer a solution to help with my preferred approach of plotting the data 'point by point' as they are calculated (or confirm that Matlab just doesn't do this sort of thing) please ?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Annotations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!