Performing a convolution in matlab

大憨熊 提交于 2019-12-25 04:55:20

问题


Alright, so I am doing some signal processing and I have a signal that is a convolution of a slit of width 83.66 microns and a response function. I want to use the convolution property of fourier transforms to find the response. The code I used is as follows:

num=xlsread('Data.xlsx','B2:C13');
y=num(13:end);
x=num(1:12);
width = 83.66;
p = width*sqrt(1/(2*pi))*sinc((x)*(width/2));
slit = abs(fftshift(ifft(p)));

figure
subplot(5,1,1);plot(x,y);title('imported data')
subplot(5,1,2);plot(x,p);title('transformed slit')
subplot(5,1,3);plot(x,slit);title('slit')

u = abs(fftshift(ifft(y)));
l = u./p;
response = abs(fftshift(fft(l)));

subplot(5,1,4);plot(x,response);title('response')

%Data Check
check = conv(slit,response,'full');
z = linspace(min(x),max(x),length(check));
subplot(5,1,5);plot(z,check./2);title('check')

With x=

-344.0000 -275.2000 -206.4000 -137.6000 -68.8000 0

Columns 7 through 12

68.8000 137.6000 206.4000 275.2000 344.0000 412.8000

and y=

Columns 1 through 5

       13771       12478       19443       69392      143737

  Columns 6 through 10

      189278      184486      188466      185023      128133

  Columns 11 through 12

       51288       10854

So what I do is input the signal, perform the fft. Then I divide by the sinc function (FT of a slit) and then ifft all of that. When I reconvolve my response with the slit I have, the two are not the same.

Any ideas or anything that I am clearly doing wrong?

来源:https://stackoverflow.com/questions/17370975/performing-a-convolution-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!