23.07.2013 Views

MATLAB/OCTAVE TUTORIAL from

MATLAB/OCTAVE TUTORIAL from

MATLAB/OCTAVE TUTORIAL from

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

plot(1:N, c)<br />

end<br />

ret = c(end);<br />

%You can save this as an m-file and run it as a function <strong>from</strong> the command line.<br />

%Just put the function in a text editor and save with a .m extension.<br />

%To make things easy, just save the function in the octave_files folder with the same name as<br />

the function.<br />

%help commands<br />

help %for each command<br />

%you can get gnuplot help by typing help at the gnuplot> prompt, you can start gnuplot in another<br />

terminal window by typing gnuplot<br />

% Hitting the uparrow will get you previously typed commands.<br />

% Setting the path to display or change octave's search path<br />

path<br />

path('/Users/andrewcohen/Desktop', LOADPATH); % for mac<br />

path(':\\Documents and Settings\\default\\desktop\\', LOADPATH); % for windows<br />

%To have your path set to include the directory /tmp automatically at Octave startup<br />

%In your home directory (on a mac, type pwd when you start octave to find it) or the folder<br />

octave_files (on a PC) make or find a file called .octaverc<br />

%Put in the line (without the starting percent sign)<br />

%LOADPATH = ['/tmp', LOADPATH];<br />

%NASTY COMMENTS FROM <strong>MATLAB</strong><br />

1/0<br />

Warning: Divide by zero.<br />

% means: you are dividing by zero<br />

x = [1 2 3 4]<br />

x(5)<br />

??? Index exceeds matrix dimensions.<br />

% means: x does not have anything at 5<br />

x(0)<br />

??? Index into matrix is negative or zero.<br />

% means: the first item in x is at position 1 and nothing can be at zero<br />

x(-1)<br />

??? Index into matrix is negative or zero.<br />

% means: a vector cannot have negative indices

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!