Thread Subject: Get variable from another m-file

Subject: Get variable from another m-file

From: Bader

Date: 25 Nov, 2009 13:04:06

Message: 1 of 10

Hi ALL,

I would like to get a specific variable in m-file, to be used in another m-file.

Can anyone help me please?

Subject: Get variable from another m-file

From: Jos (10584)

Date: 25 Nov, 2009 13:17:17

Message: 2 of 10

"Bader " <hatel-811@hotmail.com> wrote in message <heja06$p3v$1@fred.mathworks.com>...
> Hi ALL,
>
> I would like to get a specific variable in m-file, to be used in another m-file.
>
> Can anyone help me please?

use them as input and output arguments of functions

Jos

Subject: Get variable from another m-file

From: Bader

Date: 25 Nov, 2009 13:30:24

Message: 3 of 10

"Jos (10584) " <#10584@fileexchange.com> wrote in message <hejaot$cvc$1@fred.mathworks.com>...
> use them as input and output arguments of functions
>
> Jos

Jos I am not good in using functions, may u give me an example. Many Thanks

Subject: Get variable from another m-file

From: dpb

Date: 25 Nov, 2009 13:41:19

Message: 4 of 10

Bader wrote:
> "Jos (10584) " <#10584@fileexchange.com> wrote in message <hejaot$cvc$1@fred.mathworks.com>...
>> use them as input and output arguments of functions
>>
>> Jos
>
> Jos I am not good in using functions, may u give me an example. Many Thanks

Many examples in the "getting started" section of the online
documentation under "programming m-files" (or similar title, that's
otomh not looking at index/toc).

While not highly recommended in general, look at the documentation for
GLOBAL as well.

--

Subject: Get variable from another m-file

From: Bader

Date: 25 Nov, 2009 14:06:19

Message: 5 of 10

dpb <none@non.net> wrote in message <hejc68$5h5$2@news.eternal-september.org>...
> Bader wrote:
> > "Jos (10584) " <#10584@fileexchange.com> wrote in message <hejaot$cvc$1@fred.mathworks.com>...
> >> use them as input and output arguments of functions
> >>
> >> Jos
> >
> > Jos I am not good in using functions, may u give me an example. Many Thanks
>
> Many examples in the "getting started" section of the online
> documentation under "programming m-files" (or similar title, that's
> otomh not looking at index/toc).
>
> While not highly recommended in general, look at the documentation for
> GLOBAL as well.
>
> --

I think u did not catch my problem. It is..

(I have 2 GUI: no. 1, the user will execute search (sql) and will get the user ID. Then when the user click the update button, another gui should open and at the same time shows that ID gotten in the first one).

Subject: Get variable from another m-file

From: dpb

Date: 25 Nov, 2009 14:21:14

Message: 6 of 10

Bader wrote:
> dpb <none@non.net> wrote in message <hejc68$5h5$2@news.eternal-september.org>...
>> Bader wrote:
>>> "Jos (10584) " <#10584@fileexchange.com> wrote in message <hejaot$cvc$1@fred.mathworks.com>...
>>>> use them as input and output arguments of functions
>>>>
>>>> Jos
>>> Jos I am not good in using functions, may u give me an example. Many Thanks
>> Many examples in the "getting started" section of the online
>> documentation under "programming m-files" (or similar title, that's
>> otomh not looking at index/toc).
>>
>> While not highly recommended in general, look at the documentation for
>> GLOBAL as well.
>>
>> --
>
> I think u did not catch my problem. It is..
>
> (I have 2 GUI: no. 1, the user will execute search (sql) and will get
> the user ID. Then when the user click the update button, another gui
> should open and at the same time shows that ID gotten in the first
> one).

I've never written a ML GUI (and can promise that I never will :) ) so
what's the way to do something there I don't know.

Sounds like GLOBAL may be the answer; others may have better ways to
design it, I don't know.

--

Subject: Get variable from another m-file

From: riccardo

Date: 25 Nov, 2009 14:49:20

Message: 7 of 10

"Bader " <hatel-811@hotmail.com> wrote in message <hejdkr$9im$1@fred.mathworks.com>...
> dpb <none@non.net> wrote in message <hejc68$5h5$2@news.eternal-september.org>...
> > Bader wrote:
> > > "Jos (10584) " <#10584@fileexchange.com> wrote in message <hejaot$cvc$1@fred.mathworks.com>...
> > >> use them as input and output arguments of functions
> > >>
> > >> Jos
> > >
> > > Jos I am not good in using functions, may u give me an example. Many Thanks
> >
> > Many examples in the "getting started" section of the online
> > documentation under "programming m-files" (or similar title, that's
> > otomh not looking at index/toc).
> >
> > While not highly recommended in general, look at the documentation for
> > GLOBAL as well.
> >
> > --
>
> I think u did not catch my problem. It is..
>
> (I have 2 GUI: no. 1, the user will execute search (sql) and will get the user ID. Then when the user click the update button, another gui should open and at the same time shows that ID gotten in the first one).

assuming the "update" button callback kicks off the 2nd GUI, why not passing a parameter via the function interface ?
Global and persistent variables usually require careful management, to prevent undesirable side effects.

Subject: Get variable from another m-file

From: Bader

Date: 25 Nov, 2009 16:22:19

Message: 8 of 10

"Riccardo" <nothx@nospam.org> wrote in message <hejg5g$ftj$1@fred.mathworks.com>...
> "Bader " <hatel-811@hotmail.com> wrote in message <hejdkr$9im$1@fred.mathworks.com>...
> > dpb <none@non.net> wrote in message <hejc68$5h5$2@news.eternal-september.org>...
> > > Bader wrote:
> > > > "Jos (10584) " <#10584@fileexchange.com> wrote in message <hejaot$cvc$1@fred.mathworks.com>...
> > > >> use them as input and output arguments of functions
> > > >>
> > > >> Jos
> > > >
> > > > Jos I am not good in using functions, may u give me an example. Many Thanks
> > >
> > > Many examples in the "getting started" section of the online
> > > documentation under "programming m-files" (or similar title, that's
> > > otomh not looking at index/toc).
> > >
> > > While not highly recommended in general, look at the documentation for
> > > GLOBAL as well.
> > >
> > > --
> >
> > I think u did not catch my problem. It is..
> >
> > (I have 2 GUI: no. 1, the user will execute search (sql) and will get the user ID. Then when the user click the update button, another gui should open and at the same time shows that ID gotten in the first one).
>
> assuming the "update" button callback kicks off the 2nd GUI, why not passing a parameter via the function interface ?
> Global and persistent variables usually require careful management, to prevent undesirable side effects.

Riccardo, how can I pass the parameter

function btnExecute_Callback(hObject, eventdata, handles)
value = get(handles.id, 'string');


value should be shown in 2nd gui after clicking this button. Plz clarify more!

Subject: Get variable from another m-file

From: Matt Fig

Date: 25 Nov, 2009 16:34:19

Message: 9 of 10

The example answer to question #21 (and others) cover how to do these types of things.

http://www.mathworks.com/matlabcentral/fileexchange/24861-35-complete-gui-examples

Subject: Get variable from another m-file

From: ImageAnalyst

Date: 25 Nov, 2009 16:45:42

Message: 10 of 10

On Nov 25, 8:04 am, "Bader " <hatel-...@hotmail.com> wrote:
> Hi ALL,
>
> I would like to get a specific variable in m-file, to be used in another m-file.
>
> Can anyone help me please?

-----------------------------------
This is answered in this MATLAB page:
http://www.mathworks.com/support/solutions/en/data/1-1BAR8/index.html?1-1BAR8
"Subject:
How do I pass data between GUIs in MATLAB 6.5 (R13)?

Problem Description:
I would like to be able to pass data between GUIs, and control one GUI
from another GUI.

Solution:
There are multiple ways to pass information between GUIs.
[snip]"

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
get Bader 25 Nov, 2009 08:09:05
m file Bader 25 Nov, 2009 08:09:05
variable Bader 25 Nov, 2009 08:09:04
rssFeed for this Thread

Contact us at files@mathworks.com