
% EECE 568, Control Systems
% Problem 2, HW #1 
%
% M. Oishi, 10/1/09
%


% linearzed system (deviations from nominal trajectory)
linear_sys = ss(-19, 1,1,0);
t_l = 0:.01:2;
u_l = ones(size(t_l));
x0_l = -2;
y_l = lsim(linear_sys,u_l,t_l,x0_l);

% nominal trajectory
u_e = 14;
y_e = 2;

% nonlinear system
[t_nl,y_nl]=ode23('hw1_p2_circuit',t_l,0);


figure(1);
subplot(211);
plot(t_l, y_l+y_e,'r',t_nl,y_nl,'b--');
legend('Linearized System + Nominal Trajectory','Nonlinear System',4);
xlabel('time'); ylabel('v_R(t)'); title('Problem 2, Question 3');

subplot(212);
semilogy(t_l, abs(y_nl-(y_l+y_e)),'c-.');
xlabel('time'); ylabel('log(|v_R(t)-(v_{R0}(t)+\delta v_R(t))|)'); 
title('Difference between nonlinear system and linearized approximation');
grid on;

orient tall;

