Contents:

Octave resources:

  1. Type help help at the octave command line to find out about the built in documentation system

  2. Type help <keyword> to get documentation on a particular keyword, operator, or function. Here is an example of asking for documentation on the sin() function: octave:1>help sin

  3. On-line Tutorial: There are several on-line octave/MATLAB tutorials. Here is a link to one which gives a good introduction to the language: http://www.aims.ac.za/resources/tutorials/octave/

  4. On-line octave Manual: The octave manual is available as a PDF here: http://www.octave.org/docs.html

  5. octave-forge documentation: octave-forge is a library of octave functions for working on domain specific (including audio signal processing) problems. You can install  octave-forge using fink. Here is the link to the octave-forge on-line documentation:http://octave.sourceforge.net/index/

Contents

Octave Tutorial and Notes:

Contents

Getting Started with Octave Programing

The easiest way to begin writing octave programs is to begin with an existing script and modify it in a series of small increments. This approach is often effective when learning a new programming language. The idea is to start from a simple working function, strip out it's contents, and incrementally replace it with new code. After each small change the program is executed. This way when the program doesn't work as expected or generates an error message it is clear which change produced the error. You can then back out of the change and try an alternative or search through the octave documentation to find a solution.

These directions assume that you have already gone over the tutorial above and feel comfortable with creating, manipulating and displaying octave matrices.   If you want more practice you should go through the on-line tutorial also.

Directions for writing a new octave function:
  1. Make a copy of the sumDiff.m script given above.
  2. Rename the file and function to the to the name of the new function you are writing (e.g. myNewFunction) .
  3. From the octave command prompt run the new function. It should behave exactly like the original sumDiff function.
  4. Change the argument list of myNewFunction to the arguments for the new function and delete (or comment out) the body of the function left over from sumDiff.
  5. In the body of myNewFunction print out the values of the new argument list.
    function y = myNewFunction( arg0, arg1, arg2 )
    arg0
    arg1
    arg2
    y = 0
    endfunction
  6. Run the function again. This time the arguments that you pass should be printed to the console.
    octave:1> myNewFunction(1,2,[4 5 6])
    arg0 = 1
    arg1 = 2
    arg2 =
    4 5 6
    y = 10
    ans = 10
  7. Now begin inserting new code into the body of the function.  Don't add more than a couple of lines without running the script again.  
  8. Don't believe the line numbers reported in the error message too much. Often the reported line number is just after (or before) the line containing the error. You should treat the line numbers as suggestions regarding where to look for the error rather than as absolute fact. The same is true of the error messages themselves. Often  the message will indicate a different problem than the one which actually exists. This shouldn't be too surprising; if octave knew the real problem it would fix it and not bother you about it.  This is just another reason to use the incremental development approach.  After solving a few bugs you will quickly start to recognize patterns in the way the program responds and reports trouble.
Contents