Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

octave: load many functions from single file

How can I put multiple functions in one file and later get access to all of them in the octave interpreter ? I don't want to have a thousand files and want to group functions together. I'd like something like 'import' in python.

like image 784
Adrian Panasiuk Avatar asked Jan 15 '10 00:01

Adrian Panasiuk


People also ask

What is function file in Octave?

When Octave defines a function from a function file, it saves the full name of the file it read and the time stamp on the file. If the time stamp on the file changes, Octave may reload the file. When Octave is running interactively, time stamp checking normally happens at most once each time Octave prints the prompt.

How do you save a function in Octave?

Command: save options file -struct STRUCT f1 f2 … Save the named variables v1 , v2 , …, in the file file . The special filename ' - ' may be used to return the content of the variables as a string. If no variable names are listed, Octave saves all the variables in the current scope.


2 Answers

Once you have saved all your function definitions in a single script file, use source("filename") to have access to these functions within the interpreter.

like image 188
Boki Avatar answered Sep 24 '22 21:09

Boki


What you're looking for is called “script files”, defined there: http://www.gnu.org/software/octave/doc/interpreter/Script-Files.html

like image 22
Gunnlaugur Briem Avatar answered Sep 21 '22 21:09

Gunnlaugur Briem