help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calling a function within a multi-function file


From: Shai Ayal
Subject: Re: calling a function within a multi-function file
Date: Tue, 03 May 2005 16:50:43 +0300
User-agent: Mozilla Thunderbird 1.0 (X11/20041206)

There is a trick you can try:

The problem is that octave has no way to know that test2 is in test.m what you can do is convert rename test.m to say test_funcs.m , convert it to a script file by adding the statement 1; at the top, call test_funcs and you will now have access to both test and test2 functions. caveat: if you change the m-file, you'll have to reload it automatically for the functions to change. For sake of clarity, this is the test_funcs.m file I propose:

#--- test_func.m ---------------
1;
function y=test(x)
  y=x;
endfunction

function y=test2(x)
  y=2*x;
endfunction
#------------------------------

hope this helps,
Shai

Brian Blais wrote:
Hello,

If I have the following function file test.m

function y=test(x)
  y=x;
endfunction

function y=test2(x)
  y=2*x;
endfunction
%------------------------------


Is there a way to call function test2 directly, even though it is in
test.m?  I could use the source command, but then I have to do that
manually every time I change the file.  Is there another way?


            thanks,

                Brian Blais



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]