YDataSource problems
조회 수: 11 (최근 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!