help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: plot in a for loop


From: Roman.Griego
Subject: RE: plot in a for loop
Date: Thu, 3 Mar 2011 14:07:28 +0000


> -----Original Message-----
> From: William Krekeler [mailto:address@hidden
> Sent: Wednesday, March 02, 2011 3:28 PM
> To: Griego, Roman D [CLIMATE/AC/AVA]; address@hidden
> Subject: RE: plot in a for loop
> 
> Alternative solution for plotting in a loop, replace the lines inside
> the for loop with the following where newdata is the information you
> wish to plot
> 
> hold on, plot( newdata ), hold off; drawnow; pause(0.1)
> 
> This code will allow the previous plots to persist so you can see the
> iterations. Alternatively remove the hold commands to update the plots.
> 
> Bill Krekeler
> 
> -----Original Message-----
> From: address@hidden [mailto:help-octave-
> address@hidden On Behalf Of Richardson, Anthony
> Sent: Wednesday, March 02, 2011 10:24 AM
> To: Mon; address@hidden
> Subject: RE: plot in a for loop
> 
> > Morning all,
> > I know this has been addressed in the past, but I cannot find the
> > relavent
> > post in the archive.
> >
> > I am tring to plot some data in a for loop, but once the first
> > iteration
> > prints, the plot window has the focus and none of the other
> iterations
> > print.
> >
> > figure
> > #hold on
> > for i=1:size(x,1)
> > plot(x{i},y{i})
> > #drawnow
> > endfor
> >
> > "drawnow" doesn't get it, nor does "hold on"
> 
> I assume you are getting updates to the vector inside the
> loop and also want to update the plot.
> 
> The script below should point you in the right direction.
> It appends new data to the underlying handle graphics object
> each time through the loop.  (This may actually be completely
> erasing and redrawing the play each time through the loop
> (I'm not sure), but it gives the illusion of a real-time data
> plot.)
> 
> ===============================
> N = 200;
> figure (1)
> x = 0:(N-1);
> y = rand(1, length(x));
> plot(x(1), y(1));
> axis([0 N 0 1]);
> vh = get(gca,'children');
> for i=1:length(x)
>       set(vh, 'xdata',x(1:i), 'ydata', y(1:i));
>       pause(0.1);
> endfor
> ================================================
> 
> Tony Richardson
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
[rdgriego] 

Thank you for the pointers, I didn't get a chance to apply it to my code last 
night. Hopefully tomorrow night less things will be on fire and I will get a 
chance to work on it some more.

Regards,
Román


reply via email to

[Prev in Thread] Current Thread [Next in Thread]