problem with IFFT and Convolution
4 ビュー (過去 30 日間)
古いコメントを表示
I’m having difficulty with executing IFFT and convolution
I want to see the output of a system with an input sine wave x(t) and transfer function H(f). In order to get the output y(t), I used IFFT with the transfer function to convert it from the frequency domain to the time domain. After which I convoluted both h(t) and x(t) to obtain y(t).
However when I plot y(t) I get a distorted signal. Could someone please instruct me as to what I did wrong? Your help would be highly appreciated
%Transfer function (multipathmodel)
f = 0:1*10^6:30*10^6; %frequency of multipathmodel
a = 0+(7.8*10^-10)*f.^1;
l = [200 225]; %length of wire
g = [0.55 0.45];
Vp = 150*10^6;
h = 0;
for i = 1:2
temp = (g(i)*exp(-a.*l(i))).*exp((-f.*j*2*pi)*l(i)/Vp);
h = h + temp;
end
%h is in the frequency domain
%Multipathmodel
d1 = 10*log(abs(h)); %H(f)/dB
d2 = ifft(h); %Impulse response
%sine wave
fo = 3*10^6; %frequency of the sinewave
Fs = 2^nextpow2((fo*10*2)+fo); %samplingrate
Ts = 1/Fs; %sampling time interval
E = 1/fo; %duration of sinewave (t)
t = 0:Ts:E; %xaxis
x = sin(2*pi*fo*t); %sinewave equation
%convolution of sine wave and transfer function
y = conv2(x,d2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%plot transfer function
figure(1)
subplot(2,1,1)
plot(f,d1)
title('Transfer function of Twopathmodel')
xlabel('frequency')
ylabel('H(f)/dB')
grid on
%plot the sine wave
subplot(2,1,2)
plot(t,x)
title('Sine wave')
xlabel('Time secs')
ylabel('Amplitude')
grid on
%plot the impulse response of the transfer function
figure(2)
t2 = (0:E/(length(d2)-1):E);
plot(t2,d2)
%axis([0 3.5*10^-6 -1 1])
title('Impulse response')
%plot the convolution
t1 = (0:E/(length(y)-1):E);
figure(3)
plot(t1,y)
%axis([0 3.5*10^-6 -1 1])
title('Convolution')
2 件のコメント
Adam
2015 年 8 月 19 日
編集済み: Adam
2015 年 8 月 19 日
Do you have an image showing what you expect to get? Which part is wrong? The final result or some intermediate results too?
You should use:
y = conv2(x,d2, 'same');
though if you want your result to be the same length as the original signal. Convolution without any flag does full convolution resulting in a final signal that is longer than the original (off the top of my head it is the sum of the length of the filter and the signal, possibly minus 1).
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spectral Measurements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!