Problem with animated line and GUI
이전 댓글 표시
Hello guys, im working with a guide for make 2 graphics in real time with information from bluetooth: - First for orientation information (handles.axes1) - Second for proximity information (handles.axes2)
if true
function pb_start_Callback(hObject, eventdata, handles)
% hObject handle to pb_start (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global s
line = animatedline;
muestra=1;
while true
vector_datos=fscanf(s);
datos=strsplit(vec_datos,'/');
orientacion_str=datos{1};
orientacion = str2double(orientacion_str);
distancia=datos{2};
distancia = str2double(distancia);
axis([muestra-10,muestra,0,360])
addpoints(line,muestra,orientacion);
drawnow
muestra=muestra+1;
end
end
end
With my code i can graphic well the orientation in default (handles.axes2) axes, but i write axes(handles.axes1) and it doesnt work. I have tried already the option of animatedline('Parent', handles.axes1) and it doesnt work. My problem is that i need to get the orientation animatedline in axes1 and proximity in axes2, but i dont know where i should write axes(handles.axes1) or axes(handles.axes2).
댓글 수: 7
Kevin Chng
2018년 10월 10일
편집: Kevin Chng
2018년 10월 10일
Do you update your handle in the main figure script?
guidata(figure,handles);
As what i know, by default, handle does not pass to your callback.
Rubén Maestro Huesa
2018년 10월 10일
편집: Rubén Maestro Huesa
2018년 10월 10일
Kevin Chng
2018년 10월 10일
Hi, do you mind to re-arrange your code? It is very difficult for me to know which line is command and which line is not command.
Rubén Maestro Huesa
2018년 10월 10일
Kevin Chng
2018년 10월 10일
편집: Kevin Chng
2018년 10월 10일
No problem. refer to my code, how to specify the axes for plot the animated line.
In your code, there is 'gui_OpeningFcn', @transmision_en_vivo_OpeningFcn, it has updated guidata(hObject, handles).
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
h = animatedline(handles.axes1);
axis([0 4*pi -1 1])
for x = linspace(0,4*pi,10000)
y = sin(x);
addpoints(h,x,y)
drawnow limitrate
end
To run 2 animatedlines in 2 different axes or 2 different figure?
In your code, you just need to specify the axes in line=animatedline(handles.axes1).
forgot to mention that, it is better to specify the axes for axis([muestra-10,muestra,0,360])
axis(handles.axes1,[muestra-10,muestra,0,360])
Rubén Maestro Huesa
2018년 10월 10일
Kevin Chng
2018년 10월 10일
편집: Kevin Chng
2018년 10월 10일
Do you mind accept my answer if it is working for you?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!