Plot and Image printing issue on GUIDE

3 vues (au cours des 30 derniers jours)
HILAL AL KALBANI
HILAL AL KALBANI le 17 Oct 2017
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 commentaire
HILAL AL KALBANI
HILAL AL KALBANI le 18 Oct 2017
Modifié(e) : HILAL AL KALBANI le 18 Oct 2017
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

Connectez-vous pour commenter.

Réponse acceptée

Cam Salzberger
Cam Salzberger le 18 Oct 2017
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

Plus de réponses (0)

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by