Output of an LTI System through both Fourier transform and Convolution
2 次查看(过去 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
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
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))
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!