Convolution of a data with multiple sigmas
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!