MATLAB: Signal decode

5

The following input and response information is given.
H(s) = (3s + 1)/(s^2 + 2s +5)
x(t) = exp(-3t) therefore X(s) = 1/(s+3)
Y(s) = H(s)X(s)
n = [0 0 3 1]; d1 = [1 2 5]; d2 = [1 3]; d = conv (d1,d2); [r,p,k] = residue (n,d)
k1mag = abs(r(3)) k1phase = angle(r(3))*180/pi
RESULTS
r = -1 0.5 – 0.25i 0.5 + 0.25i p = -3 -1 + 2i -1 – 2i k = 0
k1mag = 0.559 k1phase = 26.6
How does one get from the above MATLAB results to the following expression?
y(t) = 1.118exp(-t)cos(2t – 26.6) – exp(-3t)

Best Answer

Assuming you have the simbolic toolbox

clc;clear; %clean up command window and variables!!!!
s=tf('s') %make s tf type
H = (3*s + 1)/(s^2 + 2*s +5) %transfer functions of system
X = 1/(s+3) %input
Y=H*X %output
[num,den]=tfdata(Y) %get the polinomial coeficients 
nums=poly2sym(num{:},'s') %get symbolic expressions
dens=poly2sym(den{:},'s') %
Yt=ilaplace(nums/dens) %get the inverse laplace transform
%Yt=(cos(2*t) + sin(2*t)/2)/exp(t) - 1/exp(3*t) %my result 
%compare both expression in a graph
tv=0:0.01:10; %make a time vector
Yt0=subs(Yt,'t',tv); %get function values
Yt1=1.118*exp(-tv).*cos(2*tv - 26.6) - exp(-3*tv); %
clf;hold on; %create a clean figure and turn aditive ploting on
plot(tv,Yt0) %matlab expression
plot(tv,Yt1,'r') %your expression
legend('my expression','your expression')
%they are very similar

I'm not sure about the results!