Animating plot with GUI

11 visualizaciones (últimos 30 días)
Ethan
Ethan el 25 de Jun. de 2011
I built a script that animated a data file by:
1. linking XDataSource and YDataSource to x and y, respectively
2. changing x and y
3. using "refreshdata" to update the plot
Worked great.
Now I'm trying to build a GUI that does this at the push of a button, but YDataSource doesn't seem to exist in the axes. My code is essentially:
x1 = 1000;
x2 = x1 - handles.window;
x = x2:x1;
y = handles.rawD(x,1);
plot(handles.data,x,y);
set(handles.data,'YDataSource','y')
set(handles.data,'XDataSource','x')
And I get the error:
??? Error using ==> set
There is no 'YDataSource' property in the 'axes' class.
When I go to the data axes properties window in the GUIDE editor, there is no YDataSource property. What's the other option?
Thanks in advance! -Ethan

Respuesta aceptada

Walter Roberson
Walter Roberson el 25 de Jun. de 2011
h = plot(handles.data,x,y);
set(h,'YDataSource','y')
set(h,'XDataSource','x')
Note: this will only work if your x and y values are vectors. In particular if your y is not a vector, then plot() will output multiple lineseries handles, and each of them needs a different YDataSource.
Note that the variables you specified ('x' and 'y') must exist in the Base Workspace for refreshdata() to be able to find them, unless you use the 'workspace' option; see http://www.mathworks.com/help/techdoc/ref/refreshdata.html
  1 comentario
Ethan
Ethan el 27 de Jun. de 2011
Ah! Perfect! Thank you very much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by