*************Aufgabe 1*********************

function s9a1
h=0.05;
N=500;
x=[1;0];
A1=[1 h; -h 1];
A2=1/(1+h^2)*[ 1 h;-h 1];
A3=[1-h^2 h; -h 1];
hold on;
for i=0:N
    x=A1*x;
    plot(x(1),x(2),'*');
end
x=[1;0];
for i=0:N 
    x=A2*x;
    plot(x(1),x(2),'d');
end
x=[1;0];
for i=0:N 
    x=A3*x;
    plot(x(1),x(2));
end
hold off;
axis equal;



************Aufgabe 3***********************

function s9a3

% file: s9a3.m

% set parameter
global c 
c=1/3; 
tf=6;                                           % integrate from t=0 ... t=tf
opt=odeset('reltol',1e-4,'abstol',1e-6);        % set tolerance
for y=[-2 -.7 -.1 .1 .7 2],                     % initial conditions
  yinit=[y;y]; 
  [T,Y]=ode45('vdp',[0 tf],yinit,opt);          % integrate
  plot(Y(:,1),Y(:,2)); hold on;                 % add to plot
end;
hold off; axis equal;
xlabel('X(t)'); ylabel('X^\prime(t)=u(t)');

-------------------------------------------------------------------------------

function deriv = vdp(t,y)

% file: vdp.m

% rhs f(t,y) of Van der Pol differential equation as a 1st order system:
%     d/dt y(t) = f(t,y)
% file: vdp.m

global c
deriv=[y(2);1/c*(y(2)-y(2)^3/3-y(1))];
