%
, whereas Octave
accepts both %
and #
.
function
can end in Octave with
either endfunction
or end
; Matlab accepts
only end
.
Plot[Sin[x], {x, 0, 2*Pi}]
but for Matlab one has to give the explicit values where
to compute the function, as in
t=linspace(0, 2*pi);
plot(t, sin(t))
linspace(a,b)
creates a list (excuse me, array) of values
equally spaced between a
and b
; the default is to
create 100 values.
linspace(0, 2*pi)
suppresses
the output. Try linspace(0,1,5)
to see the values generated.
linspace(0,1,25)
. Since the output does not fit on
one line, it is displayed with column numbers:
linspace(0,1,15)
ans =
Columns 1 through 10:
0.00000 0.07143 0.14286 0.21429 0.28571 0.35714 0.42857 0.50000 0.57143 0.64286
Columns 11 through 15:
0.71429 0.78571 0.85714 0.92857 1.00000