필터 지우기
필터 지우기

GUI with multiple figures

조회 수: 9 (최근 30일)
ARP
ARP 2017년 3월 23일
댓글: ARP 2017년 3월 27일
Hi all,
I am preparing a GUI to display two figures that I have created in a m.file. The two plots are the result of a series o calculations and number of variables.
The code for the figures is the following:
figure(1)
plot(y_axis,log_scale);
xlabel('Depth (mm)')
ylabel('Relative attenuation (dB)')
axis tight
figure (2)
imagesc(x_axis,y_axis,grayscale);
colormap(gray);
xlabel('Lateral length (mm)')
ylabel('Depth (mm)')
To start the GUI, I have defined a push button that runs the m.file. I have created axes1 and axes2 to allocate the plots.
Only works if I would have a single plot, as axes1 automatically detects the figure. To give instructions for each axes, I have created 2 push buttons. Here is what I write for each push button (only one showed for simplicity):
% --- Executes on button press in Plot1.
function Plot1_Callback(hObject, eventdata, handles)
% hObject handle to Plot1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes1)
plot(y_axis,log_scale);
xlabel('Depth (mm)')
ylabel('Relative attenuation (dB)')
axis tight
..and of course it does not work. I have seen similar questions to the topic, but they are different to my case since my plots originate from the m.file.
Any tips?
Thanks

답변 (2개)

Nagini Venkata Krishna Kumari Palem
In my understanding the issue with your code is that the callback is not executed when the push button is clicked. I was looking at the code, after an initial check I think the callback was not invoked anywhere. You may make a call to the callback function in various ways, one of the way is as follows,
pushbutton.Callback = @(~,~,~)pushbutton_Callback(hObject,eventdata,handles);
Please refer to the link below if you need more information on callbacks.
  댓글 수: 1
ARP
ARP 2017년 3월 27일
Thanks for the reply, but I don't fully understand your suggestion. I don't see how is that going to solve my problem . I create the axis in GUIDE, select create callback function, and then write the instructions for the plot under each callback functions. The push button should not be necessary. The plots should open wherever I assign them (axis1, axis2).
I can't figure out what is missing

댓글을 달려면 로그인하십시오.


ARP
ARP 2017년 3월 27일
Thanks for the reply, but I don't fully understand your suggestion. I don't see how is that going to solve my problem . I create the axis in GUIDE, select create callback function, and then write the instructions for the plot under each callback functions. The push button should not be necessary. The plots should open wherever I assign them (axis1, axis2).
I can't figure out what is missing

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by