Matlab and integrating under area of Gaussian curve for lab experiment

$\begingroup$

This is going to be a long post due to information that I am going to have to present.

A brief outline in what I am asking is, that I need to integrate a Gaussian at a specific height above the x-axis so I don't want all the integration just a certain part under the curve. I have written the code to which I believe is integration all the values under the curve which I dont not want.

Here all data and full explanation with code.

So my lab experiment is on gamma ray spectroscopy and I need to find the amount of counts underneath the curve, now this was done on a program called cassy, where we could highlight the area and it would calculate this or us, but due to a miss hap one of the data plot was not integrated correctly so I am trying to do it on matab.

Starting with a count I have already integrated and a total count of $529$ for I will use this as an example.

Actual graph of data/code enter image description here

The red portion is what I am trying to integrate.

Matlab code:

dataset = xlsread('Lab 3 Results 11.10.18 (1).xlsx','Sheet3','C4:D515');

x=dataset(:,1);

y=dataset(:,2);

plot(x,y)

So because of the random decay pattern of the sample, I extracted the data or that photo peak from the excel and fitted a Gaussian function to it using the curve fitting tool in matlab, like so.

Data Fit For Gaussian: I cherry picked the data for that peak from the raw data enter image description here

From here I took the coefficient an set up the matlab code to produce just this Gaussian fit.

enter image description here

Code dataset = xlsread('Lab 3 Results 11.10.18 (1).xlsx','Sheet3','C394:D427');

x=dataset(:,1);

a1=38.51;

b1=1179;

c1=36.51;

y=a1*exp(-((x-b1)/c1).^2);

plot(x,y)

The part in green is not what I want and the part in read is, below is the code for what I belive is the total area or the read and green, i just not sure how to remove the green portion so I can get the data just for the red.

Code For numerical integration

dataset = xlsread('Lab 3 Results 11.10.18 (1).xlsx','Sheet3','C394:D427');

x=dataset(:,1);

a1=38.51;

b1=1179;

c1=36.51;

y=a1*exp(-((x-b1)/c1).^2);

int=trapz(y)

this code give int=$783.5391$ which is not far off the $529$ done by the cassy program, and my thought are that the my code is integrating the red and green area not just the red, but I am very new to matalb and not really sure what parameters are needed to get it to integrate just the red area.

Is there some advice someone could give

$\endgroup$ 1 Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like