GUI Hold on issue
13 ビュー (過去 30 日間)
古いコメントを表示
Hello!
I'm trying to create a GUI, in short, i have an issue with one of my pushbutton functions.
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)
global data1
plot(handles.axes1,data1(:,2),data1(:,5));
This works just fine and gives me my plot.
However, i'd like to add a horizontal line in the same plot, so i used this code :
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)
global data1
plot(handles.axes1,data1(:,2),data1(:,5));
hold on
plot(handles.axes1,[min(data1(:,2)) max(data1(:,2))],[0.2 0.2],'g-');
hold off
Which essentially draws a green line in the plot, when i compile(push the button), only the green line plots and the initial plot doesn't. I cannot figure this out, please help :).
0 件のコメント
回答 (1 件)
Cris LaPierre
2021 年 7 月 14 日
Short answer, in an app, you need to specify the target axes, just like you do in the plot command.
hold(handles.axes1,'on')
plot(handles.axes1,...)
hold(handles.axes1,'off')
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!