YDataSource problems
18 次查看(过去 30 天)
显示 更早的评论
Hi there,
I'm trying to create an animated plot with data from four sensors. I got it to work with the data from one sensor using the refreshdata command. However, refreshdata didn't like plotting more than one column of data. I was hoping that the following code would work, but I get the error:
??? Error using ==> set Invalid handle object.
Error in ==> guiTest>pushbutton_Play_Callback at 450 set(h1,'YDataSource','handles.y1')
What am I doing wrong... and maybe more to the point... what's the best way to plot multiple lines in the same graph and then update it many times/sec?
A snippet of code is below. Thanks!
handles.y1 = rawData(handles.x,1);
handles.y2 = rawData(handles.x,2);
handles.y3 = rawData(handles.x,3);
handles.y4 = rawData(handles.x,4);
h1 = plot(handles.data,handles.x,handles.y1);
h2 = plot(handles.data,handles.x,handles.y2);
h3 = plot(handles.data,handles.x,handles.y3);
h4 = plot(handles.data,handles.x,handles.y4);
set(h1,'YDataSource','handles.y1')
set(h1,'XDataSource','handles.x')
set(h2,'YDataSource','handles.y2')
set(h2,'XDataSource','handles.x')
set(h3,'YDataSource','handles.y3')
set(h3,'XDataSource','handles.x')
set(h4,'YDataSource','handles.y4')
set(h4,'XDataSource','handles.x')
0 个评论
回答(1 个)
Paulo Silva
2011-7-9
Use lines instead of plots and change their xdata and ydata everytime you want to update them.
I can't understand that code, you are changing the datasource for what purpose?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!