Octave Mnl

From Biowiki
Jump to: navigation, search

Description

Octave is an open source Matlab-like computational package.

Basic Commands

  • who - list variables
  • clear - remove variables
  • system - run unix command
  • help cmd
  • pwd, cd

Matrix

  • M = [1 2 3; 4 5 6; 7 8 9]
  • M(1,:) = first row; M(:,2) = second column
  • C = A * B
  • Functions: diag

Other Functions

  • min

Looping

  • For loop
    for var = row_vector
      do something with var;
    endfor
    

Scripts

  • Use .m extension to run script directly by name.
  • Leave out semicolons to print values.
  • Comments are "#" or "%".

File I/O

  • [fid, msg]=fopen(file, "rt"); # Open text file for read access
  • [var, count] = fscanf(fid,"%f", [20,20]); # Read a [20,20] matrix of floats into var

-- TWiki Guest - 05 Jul 2006