Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Call GUI function from another GUI

Subject: Call GUI function from another GUI

From: Elena

Date: 8 Sep, 2010 21:24:20

Message: 1 of 2

Hello!
I have 2 GUI, big Main with set of functions and small showdata, which is opened by button in the Main. I use handles of main GUI, as arguments

showdata('main', handles.Main);

So I have access to handles of main GUI, but I also want to use function of main GUI, e.g. I have function in the Main GUI

function slice=GetSlice(hslider)
slice=ceil(get(hslider,'Value'));

I'm trying to call it from showdata GUI
handles.Image = varargin{2};
mainImage=guidata(handles.Image);
zslice=GetSlice(mainImage.ZSlider);

And I have error
??? Undefined function or method 'GetSlice' for input
arguments of type 'double'.

How can I call this function?

Thanks

Subject: Call GUI function from another GUI

From: Sean

Date: 8 Sep, 2010 21:55:20

Message: 2 of 2

"Elena " <e.e.belova@gmail.com> wrote in message <i68uu4$6g$1@fred.mathworks.com>...
> Hello!
> I have 2 GUI, big Main with set of functions and small showdata, which is opened by button in the Main. I use handles of main GUI, as arguments
>
> showdata('main', handles.Main);
>
> So I have access to handles of main GUI, but I also want to use function of main GUI, e.g. I have function in the Main GUI
>
> function slice=GetSlice(hslider)
> slice=ceil(get(hslider,'Value'));
>
> I'm trying to call it from showdata GUI
> handles.Image = varargin{2};
> mainImage=guidata(handles.Image);
> zslice=GetSlice(mainImage.ZSlider);
>
> And I have error
> ??? Undefined function or method 'GetSlice' for input
> arguments of type 'double'.
>
> How can I call this function?
>
> Thanks

First: Don't name your variable 'slice' as this is a MATLAB stock function.
Second: Rewrite GetSlice where you're calling it from and use setappdata/getappdata to pass the handles between the GUIs.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us