% -------------------------------------------------------------------------------------------------------------------------------------------
% @Copyright: M. Bollhoefer and V. Mehrmann
%	      Numerische Mathematik: Eine Projektorientierte Einfuehrung Fuer Ingenieure, Mathematiker und Naturwissenschaftler, Springer, 2004.
% -------------------------------------------------------------------------------------------------------------------------------------------

% --------------------------------------------------------------------------
% Adjust the system of differential equations for the CABIN model problem
% introduced during the lecture and solve it with the ode45 Matlab solver
% The solutions will be denoted by t and x.
% --------------------------------------------------------------------------

% Here your implementation of the problem !

% --------------------------------------------------------------------------
% Notice that ode45 delivers the vector with the individual time points as
% a column vector and the numerical solution x as an (n+1) x 6 matrix. For the
% graphical visualization we need it the other way round. 
% That is why we need to transpose!
% --------------------------------------------------------------------------


t=t';
x=x';

% Displacement along y-axis
y(1:3,1)=[1.5;...
          1.0;...
	  0.3];

       
for i=1:length(t)
   s(i)=STREET(t(i));
end
mn=-1;
mn=min(mn,y(1)+min(x(1,:)));
mn=min(mn,y(2)+min(x(2,:)));
mn=min(mn,y(3)+min(x(3,:)));
mx=0;
mx=max(mx,y(1)+max(x(1,:)));
mx=max(mx,y(2)+max(x(2,:)));
mx=max(mx,y(3)+max(x(3,:)));
       

figure(1)
plot(t,y(1)+x(1,:),'-g',t,y(2)+x(2,:),'-m',t,y(3)+x(3,:),'-b',t,s,'-k')

pause
 
plotcabin(t,x);
