Octave User defined Function Example
Introduction
In this tutorial, we will learn about user-defined functions in Octave. User-defined functions are stored in a separate file with the filename as the function name.
User-defined function
Let’s write a sample function to convert Fahrenheit temperature to Celsius temperature.
We will use the following conversion formula:
function [Celsius] = FahToCel(Fahrenheit) % Function: FahToCel.m % Celsius = 5*(Fahrenheit-32)/9; endfunction
Function Call
We can invoke the function with the function name and pass the parameters.
%Sample Usage % How to invoke the user defined function celsius = FahToCel(50); disp(celsius);
—
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