help-octave
[Top][All Lists]
Advanced

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

Re: How to plot multiple variables in scrolling window


From: Helios de Rosario
Subject: Re: How to plot multiple variables in scrolling window
Date: Mon, 14 Jul 2014 09:17:32 +0200

>>> El día 11/07/2014 a las 1:31, jmb <address@hidden> escribió:
> I am trying to make octave plot more than one variable in a
> 'pseudo‑scrolling' manner using the code I found at:
> 
> http://octave.1599824.n4.nabble.com/plot‑in‑a‑for‑loop‑td3331507.html

> 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(10);
> endfor
> 
> which works for one variable 'y'
> 
> Then I have tried some variations of the above for 2 variables, but
have
> been unsuccessful.  Can somebody suggest how it can be done?

The following should work:

N = 200;
figure (1)
x = 0:(N-1);
# Use sine and cosine for clearer plots
y1 = sin(pi/100*x);
y2 = cos(pi/100*x);
hold on
plot(x(1), y1(1), '.-b');
plot(x(1), y2(1), '.-r');
axis([0 N -1 1]);
vh = get(gca,'children');
for i=1:length(x)
   set(vh(1), 'xdata',x(1:i), 'ydata', y1(1:i));
   set(vh(2), 'xdata',x(1:i), 'ydata', y2(1:i));
   pause(0.10);
endfor


Plotting over the previous lines (as suggested by Kai) looks the same,
but overloads the axes with superimposed, unncecessary objects, and it
may work slower -- very slow, for too many data.

Helios


SABEMOS QUÉ HICIMOS EN 2013
365 días de Innovación
ANUARIO DE BIOMECÁNICA
http://www.ibv.org/anuario2013
______________________________

INSTITUTO DE BIOMECÁNICA DE VALENCIA
Universidad Politécnica de Valencia • Edificio 9C
Camino de Vera s/n • 46022 VALENCIA (ESPAÑA)
Tel. +34 96 387 91 60 • Fax +34 96 387 91 69
www.ibv.org

Antes de imprimir este e-mail piense bien si es necesario hacerlo.
En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección
de Datos de Carácter Personal, le informamos de que el presente mensaje
contiene información confidencial, siendo para uso exclusivo del
destinatario arriba indicado. En caso de no ser usted el destinatario
del mismo le informamos que su recepción no le autoriza a su divulgación
o reproducción por cualquier medio, debiendo destruirlo de inmediato,
rogándole lo notifique al remitente.




reply via email to

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