Octave Basics: Difference between revisions

From Octave
Jump to navigation Jump to search
(→‎Graphics: Overhaul.)
Line 17: Line 17:
=== Graphics ===
=== Graphics ===


<tt>plot | semilogx | semilogy | loglog | contour | quiver | surf | mesh | meshgrid | xlabel | ylabel | zlabel | title | grid | axis | hold | subplot | figure | print</tt>
{{manual|plot}} , {{manual|semilogx}} , {{manual|semilogy}} , {{manual|loglog}} , {{manual|contour}} , {{manual|quiver}} , {{manual|surf}} , {{manual|mesh}} , {{manual|meshgrid}} , {{manual|xlabel}} , {{manual|ylabel}} , {{manual|zlabel}} , {{manual|title}} , {{manual|grid}} , {{manual|axis}} , {{manual|hold}} , {{manual|subplot}} , {{manual|figure}} , {{manual|print}}
 
  t = 0:0.01*pi:21*pi; x = sin (t).*(exp (cos (t)) - 2*cos (4*t) + sin (t/12).^5); y = cos (t).*(exp (cos (t)) - 2*cos (4*t) + sin (t/12).^5); plot(x, y) &crarr;
  t = 0:0.01*pi:21*pi; x = sin (t).*(exp (cos (t)) - 2*cos (4*t) + sin (t/12).^5); y = cos (t).*(exp (cos (t)) - 2*cos (4*t) + sin (t/12).^5); plot(x, y) &crarr;



Revision as of 17:25, 14 June 2019

For the meaning of operators, see the GNU Octave manual.

The very basics

+ , - , * , / , ^ , pi , I , e , inf , eps , sin , cos , tan , exp , log , log10 , abs , sqrt , sign , round , ceil , floor , fix , = , , , ; , who , clear , help , lookfor

x = pi, y = floor (sin (x)), z = log (exp (2013)), z / inf

Vectors and matrices

: , .* , ./ , .^ , ' , .' , \ , length , numel , size , zeros , ones , eye , diag , rand , det , trace , inv , lu , eig , cond , expm

 x = 1:5, x(:), x(2:4), A = [11 12; 21, 22], A(1,1:end) ↵

Graphics

plot , semilogx , semilogy , loglog , contour , quiver , surf , mesh , meshgrid , xlabel , ylabel , zlabel , title , grid , axis , hold , subplot , figure , print

t = 0:0.01*pi:21*pi; x = sin (t).*(exp (cos (t)) - 2*cos (4*t) + sin (t/12).^5); y = cos (t).*(exp (cos (t)) - 2*cos (4*t) + sin (t/12).^5); plot(x, y) ↵

Scripts and functions

@ | function | return | nargin | nargout | varargin | varargout | feval | eval

f = @(x) x.^2, f(1:10) ↵
function v = cossum (x, n) v = cumsum (repmat (cos (x), 1, n));

Programming elements

== | > | < | >= | <= | != | | || | | & | && | ! | if | else | elseif | for | while |end | break | continue | pause

for i = 1:5 if (i < 3) disp (i) else disp (i^2) end end ↵

See also