Site icon TestingDocs.com

Octave Functions

Overview

In this tutorial, we will learn about Octave Functions.
We can define functions in separate external files or interactively in the command window. Octave functions can be:

Some Octave built-in functions are listed here:

https://www.testingdocs.com/octave-built-in-functions/

Define Function

The function syntax is shown below:

function return_value = name(arguments_list)
           function_body
endfunction

The function_body consists of Octave statements.

Create Function

To create a new function click the following menu option:

File >> New >> New Function…

 

Enter the new function name. Octave would create the filename with the .m extension. For example, the function Foo would be created in Foo.m function file.

The file would open in the Editor pane. We can edit and the function body and save the file.

function retval = Foo (input1, input2)
       fprintf(‘Foo Function \n’);
endfunction

 

Function Example

https://www.testingdocs.com/user-defined-function-in-octave/

Octave Tutorials

Octave Tutorial on this website can be found at:
https://www.testingdocs.com/octave-tutorial/

More information on Octave can be found on the official website:
https://www.gnu.org/software/octave/index

Exit mobile version