How do you find the Full Width Half Maximum from this graph?

3 views (last 30 days)
This is a section of my code that graphs the data from an imported wdf file (picture provided). I need help writing a code that will produce a FWHM graph from the curve seen in the picture. Can you help me please as I am new to Matlab and have no idea what to put?
spec1 = SPECTRA(4,:);
Eg = (XLIST<1150 & XLIST > 950);
Eg=+Eg;
plot(XLIST,spec1)
  2 Comments
Aquatris
Aquatris on 19 Jul 2018
Edited: Aquatris on 19 Jul 2018
see here or many other more related questions in this website.
Nichole Lanham
Nichole Lanham on 19 Jul 2018
Edited: Nichole Lanham on 19 Jul 2018
I changed my code following the one from the link. I ended up with this graph shown below. How would I go about fixing the graph? The blue function should be centered and the red lines providing the FWHM?
spec1 = SPECTRA(4,:);
Eg = (XLIST<1150 & XLIST > 950);
Eg=+Eg;
plot(XLIST,spec1)
grid on;
oneProfile = spec1;
maxValue = max(oneProfile);
aboveHalfMax = oneProfile>maxValue/2;
firstIndex = find(aboveHalfMax,1,'first');
lastIndex = find(aboveHalfMax,1,'last');
hold on;
line([firstIndex firstIndex],[0 maxValue/2],'Color','r','LineWidth',2);
line([lastIndex lastIndex],[0 maxValue/2],'Color','r','LineWidth',2);
line([firstIndex lastIndex],[maxValue/2 maxValue/2],'Color','r','LineWidth',2);

Sign in to comment.

Answers (0)

Categories

Find more on Graph and Network Algorithms 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!