frequency domain convolution problem

10 ビュー (過去 30 日間)
MENGZE WU
MENGZE WU 2023 年 2 月 20 日
編集済み: Matt J 2023 年 2 月 21 日
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)

採用された回答

Matt J
Matt J 2023 年 2 月 21 日
編集済み: Matt J 2023 年 2 月 21 日
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]);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing and Denoising についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by