Output of an LTI System through both Fourier transform and Convolution

1 次查看(过去 30 天)
I have an LTI System x(t) and h(t), and i want to get the output twice, one time using Convolution, and another time using Fourier Transform to and compare between them, but the output graphs are not very identical, is there any problem in my code below?
clear all; clc
t=-0:0.001:5;
x = (sign(t - 1) - sign(t - 3))/2; % My Input x(t)
h = (exp(-t)); % My Transfere function h(t)
y1=conv(h,x); %Getting Ouput by convolution
y11=fft(y1); % Doing TF of y(t)
x_w=fft(x); % Doing TF of x(t)
h_w=fft(h); % Doing TF of h(t)
y2=x_w.*h_w; % Getting the output s
subplot(4,1,1)
plot(t,x)
subplot(4,1,2)
plot(t,h)
subplot(4,1,3)
plot(y11)
subplot(4,1,4)
plot(y2)
  1 个评论
Jonas
Jonas 2022-5-24
try plotting the abs value of your y11 and y2 to get a clue how and why they are different at the moment. they look more similar than you think right now

请先登录,再进行评论。

回答(1 个)

Chandra
Chandra 2022-5-26
Hi,
add zero padding to the signal before converting to frequency domain because it should match the length of convolution signal.
clear all; clc;close all;
t=-0:0.001:5;
figure,
x = (sign(t - 1) - sign(t - 3))/2; % My Input x(t)
h = (exp(-t)); % My Transfere function h(t)
y1=conv(h,x); %Getting Ouput by convolution
y11=fft(y1); % Doing TF of y(t)
%% sectin that need to change%%
x_w=fft([x zeros(1,length(h)-1)]); % Doing TF of x(t) with padding
h_w=fft([h zeros(1,length(x)-1)]); % Doing TF of h(t) with padding
%% section ends%%
y2=x_w.*h_w; % Getting the output s
subplot(4,1,1)
plot(x) % remove t to avoid conflicts when variable lenght of x and h (or) give appropriate length
subplot(4,1,2)
plot(h)
subplot(4,1,3)
plot((y11))
subplot(4,1,4)
plot((y2))
refer to the link for padding zeros.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by