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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by