Animating plot with GUI
14 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Walter Roberson
2011-6-25
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
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!