Animating plot with GUI

12 Ansichten (letzte 30 Tage)
Ethan
Ethan am 25 Jun. 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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 25 Jun. 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 Kommentar
Ethan
Ethan am 27 Jun. 2011
Ah! Perfect! Thank you very much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Animation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by