Trouble trying to plot the output of an input signal with an impulse response

3 次查看(过去 30 天)
Here is my code where I took the convolution of an input signal x(t) and the impulse response h(t). I took the laplace of each signal and multiplied those laplace values. My problem is trying to plot the impulse response. I tried to define t from 0 - 10 seconds with a dt of 0.01, but this would error out when I tried to find my Laplace results for X(s) and H(s), so I removed it and it worked fine. However, I am not sure how to plot the impulse response and output response y(t) without a defined t value? Any help would be greatly appreciated. Here is my code:
syms t s;
>> x = (5/7)*exp(-t) - (12/7)*exp(-8*t); % x = x(t)
>> h = cos(2*t) + 4*sin(2*t); % h = h(t)
>> % Define the Laplace of the impulse function h(t) = cos(2t) + 4sin(2t)
>> H = laplace(cos(2*t) + 4*sin(2*t)); % H = H(s)
>> pretty(H)
s 8
------ + ------
2 2
s + 4 s + 4
% Define the Laplace of the input function x(t) = (5/7)e(-t) - (12/7)e(-8t)
>> X = laplace((5/7)*exp(-t) - (12/7)*exp(-8*t)); % X = X(s)
>> pretty(X)
5 12
--------- - ---------
7 (s + 1) 7 (s + 8)
% Define Y(s) as the convolution of x(t) * h(t) = X(s) x H(s)
Y = X*H; % Y = Y(s)
pretty(Y)
/ 5 12 \ / s 8 \
| --------- - --------- | | ------ + ------ |
\ 7 (s + 1) 7 (s + 8) / | 2 2 |
\ s + 4 s + 4 /
% Define the Inverse Laplace of Y(s) = [(5/(7(s + 1))) - (12/(7(s + 8)))]*[(s/(s^2 + 4) + (8/(s^2 + 4)]
y = ilaplace(Y); % y = y(t)
pretty(y)
exp(-t) - cos(2 t)
subplot(312)
plot(t,x);
Error using plot
Data must be numeric, datetime, duration or an array convertible to double.

回答(2 个)

Star Strider
Star Strider 2022-6-4
Use the fplot function —
syms t s;
x = (5/7)*exp(-t) - (12/7)*exp(-8*t); % x = x(t)
h = cos(2*t) + 4*sin(2*t); % h = h(t)
% Define the Laplace of the impulse function h(t) = cos(2t) + 4sin(2t)
H = laplace(cos(2*t) + 4*sin(2*t)); % H = H(s)
% pretty(H)
H
H = 
% Define the Laplace of the input function x(t) = (5/7)e(-t) - (12/7)e(-8t)
X = laplace((5/7)*exp(-t) - (12/7)*exp(-8*t)); % X = X(s)
% pretty(X)
X
X = 
% Define Y(s) as the convolution of x(t) * h(t) = X(s) x H(s)
Y = X*H; % Y = Y(s)
% pretty(Y)
Y
Y = 
% Define the Inverse Laplace of Y(s) = [(5/(7(s + 1))) - (12/(7(s + 8)))]*[(s/(s^2 + 4) + (8/(s^2 + 4)]
y = ilaplace(Y); % y = y(t)
% pretty(y)
subplot(312)
fplot(x, [0 10]);
grid
.

tedros
tedros 2024-4-16
how to find the out put y(t) of a state matric

类别

Help CenterFile Exchange 中查找有关 Calculus 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by