Convolution of a data with multiple sigmas

2 views (last 30 days)
I am trying to perform convolution on the attached data file (W_NAIF.mat). The input is shown in (spectrum.png) and the desired output in shown in (Exp.png).
Here,
Sigma = (-0.00789) + (0.06769)*E(i) + (0.021159)*(E(i)^2); [E(i) = bins at x-axis]
Can you please suggest what am I doing wrong with my code?
The code I am using for this is:
AAA=W_NAIF/sum(W_NAIF); %%I presume W_NAIF is imported data
numEbins = 1026;
E=linspace(0,10,numEbins); % Energy bins
newSPECU(1:numEbins,1)=0;
for i=1:(numEbins-1)
%new sigma for each energy
sigmaFilter(i) = (-0.00789) + (0.06769)*E(i) + (0.021159)*(E(i)^2);
% Gaussian function with new sigma for each energy and moving mean based on current energy
gaussFilter(i) = (1/sqrt(2*pi* (sigmaFilter(i)^2)))*exp(-(E(i)-((E(i)+E(i+1))/2)))/(2*(sigmaFilter(i)^2));
end
gaussFilter(1,1026)=0;
% a way to handle the edge cases is to just normalize the computed normal (Gaussian) distribution
% (the edge cases being very low and very high energies)
% but this may not be the best way to do that
gaussFilter = gaussFilter/sum(gaussFilter);
newSPECU = (AAA').*gaussFilter; % ".*" is elemental multiplication
%%
figure(1);
stairs(E,newSPECU);
set(gca,'YScale','log');
xlabel('Energy Deposited (MeV)');
ylabel('Counts');
title('Geant4 Gamma energy spectra (NaI NEAR - Tap Water)');
grid minor;
grid on;
% THIS CODE IS NOT DOING A GOOD JOB AT THIS TASK.

Answers (0)

Categories

Find more on Time Series in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!