Animating plot with GUI

10 vues (au cours des 30 derniers jours)
Ethan
Ethan le 25 Juin 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

Réponse acceptée

Walter Roberson
Walter Roberson le 25 Juin 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 commentaire
Ethan
Ethan le 27 Juin 2011
Ah! Perfect! Thank you very much!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Animation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by