Cleveland State University

Department of Electrical and Computer Engineering

 

EEC 510

Linear Systems

 


 


function Chen220(dt)

 

% function Chen220(dt).

% Simulate the electrical circuit from Problem 2.20 in Chenís book.

% This m-file demonstrates various Matlab capabilities, along with

% the superposition property of linear systems.

% INPUTS:

%†† dt is the step size (default = 0.005).

 

if ~exist('dt', 'var')

†† dt = 0.005;

end

 

% Initialize the capacitance, inductance, and resistance values.

C1 = 400e-4;

C2 = 500e-4;

L1 = 60e-3;

R1 = 2;

R2 = 3;

 

% Set up the system matrices and create a system object.

A = [0 0 1/C1; 0 0 1/C2; -1/L1 -1/L1 -(R1+R2)/L1];

B = [0 -1/C1; 0 0; 1/L1 R1/L1];

C = [-1 -1 -R1];

D = [1 R1];

sys = ss(A, B, C, D);

 

close 'all'; % close all open figures

 

% Simulate and plot the zero state response.

figure;

tf = 4;

t = 0 : dt : tf;

N = size(t, 2);

u = [sin(t)' zeros(N, 1)];

[ysine, t] = lsim(sys, u, t);

plot(t, ysine);

title('Zero-State Response');

 

% Simulate and plot the initial condition response.

figure;

x0 = [0; 1; 0];

[yinitial, t] = initial(sys, x0, t);

plot(t, yinitial);

title('Initial Condition Response');

 

% Simulate the total response.

x = x0;

u = [sin(0); 0];

yarray = [C * x + D * u];

for t = dt : dt : tf

†† xdot = A * x + B * u;

†† x = x + xdot * dt;

†† y = C * x + D * u;

†† yarray = [yarray y];

u = [sin(t); 0];

end

figure;

t = 0 : dt : tf;

% Compare the total response obtained manually with the total

% response obtained by superimposing the zero-state and the

% zero-input responses.

plot(t, ysine+yinitial, '-', t, yarray, '--');

title('Total Response');

 


Professor Simon's Home Page

Department of Electrical and Computer Engineering

Cleveland State University


Last Revised: July 22, 2002