FAQ: Difference between revisions

Jump to navigation Jump to search
5 bytes added ,  16 November 2012
Line 383: Line 383:
First of all, make sure you understand [http://www.gnu.org/software/octave/doc/interpreter/Script-Files.html the difference between script files and function files]. If you want to execute a function defined in a file, just call the function like any other Octave function: <code>foo(arg1, arg2);</code>
First of all, make sure you understand [http://www.gnu.org/software/octave/doc/interpreter/Script-Files.html the difference between script files and function files]. If you want to execute a function defined in a file, just call the function like any other Octave function: <code>foo(arg1, arg2);</code>


To execute a script from within Octave, just type its name without the .m extension. So, if you have a script called <code>foo.m</code>, just type <code>foo</code> from within Octave to execute. You have to make sure that the script is in your current path. Type <code>path</code> in Octave to see what this path is.
To execute a script from within Octave, just type its name without the .m extension. Thus, if you have a script called <code>foo.m</code>, just type <code>foo</code> from within Octave to execute it. You have to make sure that the script is in your current path. Type <code>path</code> in Octave to see what this path is.


If the script name has characters that are not valid for an Octave identifier, or if you do not want to use addpath to add the script's location to the current path, you can use the <code>run</code> function instead:
If the script name has characters that are not valid for an Octave identifier, or if you do not want to use addpath to add the script's location to the current path, you can use the <code>run</code> function instead:

Navigation menu