From: Wen Zhe on
Hi guys (and gals),

Just a quick question, basically i have this M file that does some calculation and outputs value in a variable called u(t,r). Note the values are indexed.

Now, in a seperate M file, i want to call the previous M file to get values of u(t,r). How would i be able to do so?

Any help appreciated. Thanks!

Regards,

Wen Zhe
From: Wen Zhe on
bump!

"Wen Zhe " <wenzhe2092(a)hotmail.com> wrote in message <hn8duj$d0q$1(a)fred.mathworks.com>...
> Hi guys (and gals),
>
> Just a quick question, basically i have this M file that does some calculation and outputs value in a variable called u(t,r). Note the values are indexed.
>
> Now, in a seperate M file, i want to call the previous M file to get values of u(t,r). How would i be able to do so?
>
> Any help appreciated. Thanks!
>
> Regards,
>
> Wen Zhe
From: Walter Roberson on
Wen Zhe wrote:

> Just a quick question, basically i have this M file that does some
> calculation and outputs value in a variable called u(t,r). Note the
> values are indexed.

> Now, in a seperate M file, i want to call the previous M file to get
> values of u(t,r). How would i be able to do so?
> Any help appreciated. Thanks!

If the first m file is a script (no 'function' line in it) then in the
second m file just give the name of the first m file without the '.m'
extension and it will be run in the workspace appropriate for the second
file, leaving behind its variables.

If the first m file is a function, then it has its own workspace, and
variables in the workspace disappear after the function finishes
executing (except for 'global' and 'persistent' variables, and some
tricks involving passing the handles of subfunctions out of the
routine.) In this case, there is no way to access the variables after
the function has run, not without changes to the first m file to
deliberately make the variables available.
From: Wen Zhe on
Thanks for the reply Walter.

So what are the tricks involved in getting the values in the variales from the first M file into the second M file?

Many thanks,

Wen Zhe

Walter Roberson <roberson(a)hushmail.com> wrote in message <hn8lat$22t$1(a)canopus.cc.umanitoba.ca>...
> Wen Zhe wrote:
>
> > Just a quick question, basically i have this M file that does some
> > calculation and outputs value in a variable called u(t,r). Note the
> > values are indexed.
>
> > Now, in a seperate M file, i want to call the previous M file to get
> > values of u(t,r). How would i be able to do so?
> > Any help appreciated. Thanks!
>
> If the first m file is a script (no 'function' line in it) then in the
> second m file just give the name of the first m file without the '.m'
> extension and it will be run in the workspace appropriate for the second
> file, leaving behind its variables.
>
> If the first m file is a function, then it has its own workspace, and
> variables in the workspace disappear after the function finishes
> executing (except for 'global' and 'persistent' variables, and some
> tricks involving passing the handles of subfunctions out of the
> routine.) In this case, there is no way to access the variables after
> the function has run, not without changes to the first m file to
> deliberately make the variables available.
 | 
Pages: 1
Prev: Triple quad
Next: Error importing excel