Plot and Image printing issue on GUIDE

조회 수: 3 (최근 30일)
HILAL AL KALBANI
HILAL AL KALBANI 2017년 10월 17일
답변: Cam Salzberger 2017년 10월 18일
Hi Folks... I am working on my final project based on designing a matlab PID control tuner using GUIDE as a control panel for sending inputs to an mfile and receiving the results via the workspace.
I put two axes on my GUI, axes1 for plotting the figure that is called from workspace and the other axes (axes2) is placed for reading an image.
The Issue: when I hit the push button once, the figure is printed on axes1 and the image is printed on axes2 which is fine. However, when hit the push button again the figure is printed on axes2 not on axes1 ???!!!
It seems to me that axes2 becomes an active component means that the image and the figure are printed together when the push button is pressed again.. Could anyone help me on this???
I do appreciate your help lads in advance
  댓글 수: 1
HILAL AL KALBANI
HILAL AL KALBANI 2017년 10월 18일
편집: HILAL AL KALBANI 2017년 10월 18일
Forget to attach the code..
graph_1 =(handles.Performance_Graph);
graph_1 = evalin('base','figure_1'); %read the figure from workspace
PI_1 = imread('PI_Ideal_controller_with_first_order_filter.PNG');
imshow(PI_1, 'Parent', (axes(handles.block_diagram)));
where:
Performance_Graph = axes1
block_diagram = axes2

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

채택된 답변

Cam Salzberger
Cam Salzberger 2017년 10월 18일
Hello Hilal,
Rather than calling "axes" in your "imshow" call, just provide the handle to the correct axes there.
Now I'm not sure what you mean by "the figure is printed". What is "figure_1" in the workspace.
I actually don't know how "the figure is printed" ever, since this code just appears to assign to the variable "graph_1" the handle to an axes, then reassign graph_1 to whatever is in "figure_1" in the base workspace. I think you mean to take some data from the base workspace, and update "handles.Performance_Graph" with that in some way, which you are currently not doing (as far as this code indicates).
Also, as a style guide, try to avoid using the base workspace and "eval" or "evalin" wherever possible. They tend to be unreliable when dealing with users. If you need to store data somewhere in your GUI, consider the 'UserData' property of a UI component, or get/setappdata.
-Cam

추가 답변 (0개)

카테고리

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