例 octave:1> function xdot = f(x,t) > k = 1.0; > xdot(1) = x(2); > xdot(2) = -k * x(1); > endfunction octave:2> x0 = [0; 1]; octave:4> t = linspace(0,4,10)' t = 0.00000 0.44444 0.88889 1.33333 1.77778 2.22222 2.66667 3.11111 3.55556 4.00000 octave:5> x = lsode("f", x0, t); octave:6> plot (t,x) octave:7> plot (t,x(:,1)) ooctave:8> gplot x octave:11> tx=[t x(:,1)]; octave:12> gplot tx
なお, function の戻り値は xdot 以外でもよい.