Problem with axes and animatedline
조회 수: 10 (최근 30일)
이전 댓글 표시
Hi! My problem is that when I try to plot an animatedline into axis1, instead of plotting there, another window is opened. also, when I try to use axes(handles.axes1) it says:
ans =
handle to deleted Axes.
Mi code is here:
function Medir_Callback(hObject, eventdata, handles)
s = abrir_puerto();
handles.x=1:20;
handles.h=animatedline('Marker','o','LineWidth',1,'Color','k');
for i=1:(length(handles.x))
handles.distancia(i)=fscanf(s,'%d');
addpoints(handles.h,i,handles.distancia(i));
drawnow;
end
cerrrar_puerto(s);
I want it to be plotted in my Matlab GUI. Although i have tried to define axes in here, i haven't been able to fix the error that appears below
handles.h=animatedline('Marker','o','LineWidth',1,'Color','k','Parent', handles.axes1);
Error using animatedline While setting property 'Parent' of class 'AnimatedLine': Cannot set property to a deleted object
Thanks, Itziar
댓글 수: 0
답변 (1개)
Adam
2017년 2월 23일
편집: Adam
2017년 2월 23일
The problem here is not with the animated line plotting it is what you post at the top - that your axes no longer exist. That is why it creates a new axes when you don't specify one and why it throws an error when you do.
Judging by the name of your axes I assume they are axes defined in GUIDE? If so I'm not sure how you would end up deleting the axes. You should search through your code for any instruction that involves handles.axes1 and check that you are not explicitly deleting the axes. Axes in a GUIDE GUI have the same life time as the GUI itself unless you explicitly delete them.
I notice though also that your callback does not include a
guidata( hObject, handles )
call so any changes you make to the handles structure there will be lost after the callback. That in itself is not the cause of this particular problem, but it is a hint that you might have done something incorrect with the handles structure previously also.
참고 항목
카테고리
Help Center 및 File Exchange에서 Animation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!