%            
%         MATH-401 * Spring 2010 * Victor Matveev
%
%  Analyze solutions of differential equation dy/dt=y-t

figure(1);
hold on;

f = @(t,y) y - t;

lgnd = { };

styleArray = {'b-', 'b:', 'b--', 'b-.', ' ', 'k*-', 'kd-', 'kv-', 'k+-'};
icArray = [3: -0.5 : -1];


for i = 1 : length(icArray)
    
    y0 = icArray(i);
    
    if y0 == 1
        lgnd = [lgnd, 'Separatrix'];
        style = 'r-';
        lw = 2;
    else
        lgnd = [lgnd, ['y_0=', num2str(y0)] ];
        style = styleArray{i};
        lw = 1;
    end
    
    [T, Y] = ode45(f, [0 2], y0);
    plot(T, Y, style, 'linewidth', lw);
end;

axis([0 2 -2 4]);
legend(lgnd);

xlabel('t (time)', 'fontsize', 10);
ylabel('y(t) (solution)', 'fontsize', 10);
title('Solutions of differential equation dy/dt=y-t', 'fontsize', 12);
