% van der Poll oscillator
clear
clc;
# vymazeme nastaveni vykreslovani
__gnuplot_raw__ "reset;";
# nastavuje opet vykresleni plnou carou
__gnuplot_set__ data style lines;
__gnuplot_set__ xrange [:]
__gnuplot_set__ yrange [:]
% -----------------------------------------------
printf("van der Polluv oscilator\n");
% -----------------------------------------------
global mu
mu=10;
% -----------------------------------------------
# pocatecni podminky
x0=[4; 0];
% -----------------------------------------------
# definice diferencialni rovnice
function xdot = vdpoll(x,t)
global mu;
  xdot = [x(2); -mu*(x(1).^2-1).*x(2)-x(1)];
end
% -----------------------------------------------
# oblast integrace
t=linspace(0,100,5000);
vdp=lsode( "vdpoll",x0, t);
% -----------------------------------------------
% vykresleni zavislosti
% vykresleni osy x
__gnuplot_set__ xzeroaxis lt -1
__gnuplot_set__ nokey
__gnuplot_set__ tics out
__gnuplot_set__ grid
__gnuplot_set__ mxtics
__gnuplot_set__ mytics
% popisky obrazku
__gnuplot_set__ xlabel "t/s"
__gnuplot_set__ ylabel "x/m"
plot(t,vdp(:,1))
printf ("Stisknete libovolnou klavesu...\n");
pause
% vykresleni rychlosti v zavislosti na poloze ("fazovy diagram")
__gnuplot_set__ xzeroaxis lt -1
__gnuplot_set__ xlabel "x/m"
__gnuplot_set__ ylabel "y/m.s^{-1}"
plot(vdp(:,1),vdp(:,2))	
