From: Piter_ on 26 Mar 2010 12:33 Hi all. Is it possible to define a matlab function inside of matlab script? Like in python? Thanks. Petro
From: us on 26 Mar 2010 12:39 Piter_ <x.piter(a)gmail.com> wrote in message <2d5e82dc-3a1c-4f91-bdb7-8a9776ff34c8(a)q16g2000yqq.googlegroups.com>... > Hi all. > Is it possible to define a matlab function inside of matlab script? > Like in python? > Thanks. > Petro ....only anonymous function (handles) or INLINE objects... us
From: Matt J on 26 Mar 2010 12:47 Piter_ <x.piter(a)gmail.com> wrote in message <2d5e82dc-3a1c-4f91-bdb7-8a9776ff34c8(a)q16g2000yqq.googlegroups.com>... > Hi all. > Is it possible to define a matlab function inside of matlab script? ====== The word "script" is often misused in this forum. Are you sure you mean "script" and not "function file"? In function files, you can have sub-functions, nested functions, and anonymous functions.
From: Piter_ on 26 Mar 2010 13:23 On Mar 26, 5:47 pm, "Matt J " <mattjacREM...(a)THISieee.spam> wrote: > Piter_ <x.pi...(a)gmail.com> wrote in message <2d5e82dc-3a1c-4f91-bdb7-8a9776ff3...(a)q16g2000yqq.googlegroups.com>... > > Hi all. > > Is it possible to define a matlab function inside of matlab script? > > ====== > > The word "script" is often misused in this forum. Are you sure you mean "script" and not "function file"? In function files, you can have sub-functions, nested functions, and anonymous functions. Yes I was talking about script, not function file. I just wanted to keep all calculations in one file, without separate function file. But it seems to be impossible.
From: Steven Lord on 26 Mar 2010 15:21 "Piter_" <x.piter(a)gmail.com> wrote in message news:c63ba51c-7d4b-4540-ae41-8e557e8ea463(a)i25g2000yqm.googlegroups.com... > On Mar 26, 5:47 pm, "Matt J " <mattjacREM...(a)THISieee.spam> wrote: > > Piter_ <x.pi...(a)gmail.com> wrote in message > > <2d5e82dc-3a1c-4f91-bdb7-8a9776ff3...(a)q16g2000yqq.googlegroups.com>... > > > Hi all. > > > Is it possible to define a matlab function inside of matlab script? > > > > ====== > > > > The word "script" is often misused in this forum. Are you sure you mean > > "script" and not "function file"? In function files, you can have > > sub-functions, nested functions, and anonymous functions. > > Yes I was talking about script, not function file. > I just wanted to keep all calculations in one file, without separate > function file. > But it seems to be impossible. If you try to define a function inside a script file (without of course defining the function at the _beginning_ of the script file, which would turn the file into a function file) you will receive an error message that clearly states that function definitions cannot be included in a script file or at the prompt. If you want to keep all your calculations in one file, you could write one main function and have that main function call various subfunctions also defined inside the file, or nested functions defined inside the main function, or some combination of the two. Search the documentation for "subfunction" or "nested function" for more information about these approaches. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
|
Pages: 1 Prev: mobile project using matlab Next: help with NNSYSID neural networks toolbox |