No BSD License  

Highlights from
Signals & Systems: Continuous and Discrete, 4e Companion Software

from Signals & Systems: Continuous and Discrete, 4e Companion Software by Rodger Ziemer
Companion Software for Signals & Systems: Continuous and Discrete, 4e

c6ex7.m
%	lsim plot for Example 6-7
%
v0 = -2;					% Define IC value
t = 0:.05:40;			% Define time variable
num = [1 0];
den = [1 1];			% Define H(s) numerator and denominator polynomials
v = 5*cos(2*t)-v0;	% Define input in time domain; include IC
y_sim = lsim(num, den, v, t);	% Use lsim( ) to get output (without y = lsim( ), plot is done)
y_anal = (1-v0)*exp(-t)+4*(cos(2*t)-.5*sin(2*t));	% Analytical output for comparison
% Plot simulated and analytically computed output
subplot(2,1,1),plot(t, y_sim), xlabel('t'), ylabel('sim. y(t)')
subplot(2,1,2),plot(t, y_anal), xlabel('t'), ylabel('anal. y(t)')

Contact us at files@mathworks.com