|
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@hushmail.com> wrote in message <hn8lat$22t$1@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.
|