3

I need a help with MatLab GUI . I have a GUI with an axes on it, and a function plotData(axes,data) which has axes as parameter. The GUI has a button "plot Data".

How can I do the following: When the button is clicked, call the function plotData with the parameter axes1 and the data that I want to plot? I want the plot to be directed to axes1 which exists in the GUI.

It's suppose to be simple, but when I send the axes as parameter it doesn't plot on the GUI, or maybe it does but I cant see it. It works fine for me without the function: just to plot the data. but to plot the data it's not 1 row :).

i tried calling ax which storing the GUI's axes handle on different M file, but since i call it as a function from different M file nothing happens with the GUI axes handle but it also not returning any error.

Wagdi
  • 119
  • 6

1 Answers1

1

Side remark: Your question is a bit unclear: if you added small code snippet to illustrate what you have tried, better answers could be provided.

To the question at hand:

Have you tried directing the plot to axis1 in plotData?

function [] = plotData( ax, data )
% make ax the current axes for plot
axes( ax ); 
% continue with plotting the data 
% ...

You can achieve the effect of axes( ax ); in a more efficient way through the specific plot commands you are using. For example, if you are using simple plot

plot( ax, data ); % plots data to axes ax

check the documentation of the specific plot command you are using for the axes argument.

Shai
  • 111,146
  • 38
  • 238
  • 371
  • hello Shai and thanks for your reply . the problem is the function is in external m-file and not the same one as where the gui m file is. – Wagdi Jan 07 '13 at 16:29
  • as long as you have `ax` storing the GUI's axes handle, it does not matter if `plotData` is in a different m file. Please try it out and post your results in your question, so other will be able to assist as well. – Shai Jan 07 '13 at 16:39