%Math 316 - Spring 2017
%MATLAB code for System4 of Chapter 7 
%Written by M. Motamed @ UNM 
%===========================================================
%Unique solution for the ODE system: y'=Py + g(t) 
%with P =[-2 1;1 -2] and g(t)=[2e^(-t); 3t]
%IC: y0=[1;1] at t0=0
%===========================================================

%Plotting the solution
t0=0;  %initial time
T=2;   %final time
t=linspace(t0,T,1000);
y1=(-2/3)*exp(-3*t)+(3+t).*exp(-t)+t-4/3;
y2=(2/3)*exp(-3*t)+(2+t).*exp(-t)+2*t-5/3;


figure
plot(t,y1,'b-',t,y2,'r-')
legend('y1(t)','y2(t)')
xlabel('t')
ylabel('y(t)')
set(gca,'fontsize', 20);

figure 
plot(y1,y2,'b-','Linewidth',2)
xlabel('y1(t)')
ylabel('y2(t)')
set(gca,'fontsize', 20);