Computers

Octave Functions

Octave Functions

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:

  • Built-In Functions
  • User-defined Functions

Some Octave built-in functions are listed here:

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…

 

Octave 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

 

Octave Functions

Function Example

—

Octave Tutorials

Octave Tutorial on this website can be found at:

https://www.testingdocs.com/octave-tutorial/