Chapter 5. Extensions: Write Your Own Octave Functions
In this chapter, you will learn how to write your own Octave functions. This will not only enable you to utilize more of Octave's built-in functionality, it also makes it possible to extend Octave to do pretty much anything you want it to in a highly reusable and modular manner.
After reading this chapter, you will be able to:
Write your own Octave functions.
Check and validate user inputs to the functions.
Write function help text.
Define mathematical functions that can be used by Octave to solve different numerical problems.
Perform simple debugging of your functions.
Vectorize your code.
Your first Octave function
In general, the syntax for a function is:
function [output1, output2, ...] = functionname(input1,input2,...) do something (body) endfunction
where output1, output2, ..
. are the output variables generated by the function and input1, input2, ..
. are inputs to the function and are also referred to as input arguments. The function...