From: Walter Roberson on
Marco wrote:
> I would like to avoid having a collection of separate files -
> occasionally, for a demostration, it would be nicer to have all the
> functions one needs together with the script in a single file.
>
> Is it possible at least to have all the functions inside a single
> file, which is separate from the script m-file?

You would have to name the first function in the .m file the same as the
file name, and you would have to _call_ that function from the script.
That function would have to either return the handles to all the other
functions or else it would have to return the handle to a function which
is referenced somehow (e.g., by string or integer index.)

It is not possible to toss a bunch of functions into one file and call
upon them by name; there is no Matlab "library" file.
From: Steven Lord on

"Marco" <marcdein(a)gmail.com> wrote in message
news:e2cf8f17-3720-4023-a8da-7938f4b3b1ff(a)q23g2000vba.googlegroups.com...
>I would like to avoid having a collection of separate files -
> occasionally, for a demostration, it would be nicer to have all the
> functions one needs together with the script in a single file.

Then make your main script the main function in the file and call the other
functions as subfunctions.

> Is it possible at least to have all the functions inside a single
> file, which is separate from the script m-file?

Yes ... but then you need to do something a little tricky to get access to
them from the script. Better (in my opinion) to simply to make your script
into the main function of the file.

Alternately, if these functions are ONLY going to be used by your script and
you want to prevent other scripts or functions outside your demonstration
directory from accessing them, make them private.

http://www.mathworks.com/access/helpdesk/help/techdoc/matlab_prog/f4-70335.html

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com