octave:octave
This is an old revision of the document!
Table of Contents
Octave syntax and library overview
function
function retval = myfunction(param1, param2) retval = param1 + param2; end;
string array
myarray = { 'hello', 'world' };
if then else
for while
switch case
yesno = "yes" switch yesno case {"Yes" "yes" "YES" "y" "Y"} value = 1; case {"No" "no" "NO" "n" "N"} value = 0; case "blah" value = 42; otherwise error ("invalid value"); endswitch
Note: In matlab the endswitch
should be replaced by end
Links
More complex examples
rootfolder = pwd % Print Working Directory - specifies root folder so we don't have to cd for s=scans scanfolder=sprintf('ret_scan%02d', s) folders=dir([rootfolder,'/',scanfolder,'/*_bg']) numfolders=size(folders); folderiterator = 1:numfolders(1); for folder=folderiterator files=dir([rootfolder,'/',scanfolder,'/',folders(folder).name,'/*.mat']) numfiles=size(files); fileiterator = 1:numfiles(1); for file=fileiterator file filename=[rootfolder,'/',scanfolder,'/',folders(folder).name,'/',files(file).name] %filename load (filename) % Loads the bg-file (no laser) end; end; end;
octave/octave.1218030312.txt.gz · Last modified: 2008/08/06 15:45 by deva