frequency domain convolution problem

9 Ansichten (letzte 30 Tage)
MENGZE WU
MENGZE WU am 20 Feb. 2023
Bearbeitet: Matt J am 21 Feb. 2023
I have two rectangular signals in time domain, both of them have amptitude of 1, but different width. The signal 1 have width of 300 and siganl 2 have width of 600. If they were mutiply in time domain, the outcome will be only signal 1, so the output spectrum should be exactly the same as signal 1.
Since the multiplication of the time domain should be equal to convolution of frequency domain, so I convolve their spectrum. The output should be the same as signal 1 spectrum, but instead I get rubbish.
What have I done wrong? Thanks!
clear all
fs = 1;
Tm = 150/fs;
T = Tm/2;
f = linspace(1e-4,0.5,1e6);
figure
Signal_1 = Tm*sin(2*pi*T.*f./fs)./(2*pi*T.*f./fs); % Signal 1 spectrum, sinc function
plot(f, abs(Signal_1))
Tm2 = 300/fs;
T2 = Tm/2;
Signal_2 = Tm2*sin(2*pi*T2.*f./fs)./(2*pi*T2.*f./fs); % Signal 2 spectrum, also sinc function
plot(f, abs(Signal_2))
Output = conv(Signal_1, Signal_2, "same"); % Convolution of Signal 1 and Signal 2 in frequency domain
plot(f, Output)

Akzeptierte Antwort

Matt J
Matt J am 21 Feb. 2023
Bearbeitet: Matt J am 21 Feb. 2023
You have only generated half a sinc, rather than a full sinc from -infinity to +infinity.
Keep in mind as well that there will be discretization effects from truncating the sincs to a a finite window and from discrete sampling.
fs = 1;
Tm = 150/fs;
T = Tm/2;
f = linspace(-0.5,0.5,1e4);
Signal_1 = Tm*sin(2*pi*T.*f./fs)./(2*pi*T.*f./fs); % Signal 1 spectrum, sinc function
Tm2 = 300/fs;
T2 = Tm/2;
Signal_2 = Tm2*sin(2*pi*T2.*f./fs)./(2*pi*T2.*f./fs); % Signal 2 spectrum, also sinc function
Output = conv(Signal_1, Signal_2, "same")*(f(2)-f(1)); % Convolution of Signal 1 and Signal 2 in frequency domain
plot(f, Signal_2,'-k',f(1:5:end), Output(1:5:end),'x');legend('Signal 2','Output')
xlim([-0.05,+0.05]);

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by