Area under each peak
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
1 개 추천
Hi, I have a TGA derivative plot with three peaks (two prominant peaks and one shoulder) and I want to get individual gaussian functions to get the area under each peak (which tells how much mass is reduces during heating), could you please tell me how get area under each curve. and also how to get full width half maximum, FWHM and peak center values too.
Thanks
채택된 답변
Star Strider
2016년 7월 8일
This was certainly an interesting challenge!
The loop first selects a range of x and y values to make the fit easier, then uses fminsearch to do the fit, calculates the area under the respective Gaussian using trapz and saves it to ‘AUC’, then uses fzero to calculate the full-width-half-maximum value and saves it to ‘FWHM’. The plot simply shows the fitted Gaussians, not ‘AUC’ or ‘FWHM’.
The code:
[d,s,r] = xlsread('chamila De Silva Q16N2.csv');
x = d(:,1);
y = d(:,2);
gausfcn = @(b,x) b(1) .* exp(-((x-b(2)).^2)./b(3)); % Gaussian Function
SSECF = @(b,x,y) sum((y - gausfcn(b,x)).^2); % Sum-Squared-Error Cost Function
[pks,locs] = findpeaks(y, 'MinPeakDist',30, 'MinPeakHeight',0.05); % Find Centres
q = x(locs);
for k1 = 1:size(pks,1)
idxrng = locs(k1)-25 : locs(k1)+25;
[Parms(:,k1), SSE(k1)] = fminsearch(@(b)SSECF(b,x(idxrng),y(idxrng)), [pks(k1); x(locs(k1)); 1]);
AUC(k1) = trapz(x, gausfcn(Parms(:,k1),x));
FWHM(k1) = 2*(x(locs(k1)) - fzero(@(x) gausfcn(Parms(:,k1),x) - pks(k1)/2, x(locs(k1))-5));
end
figure(1)
plot(x, y, 'LineWidth',1.5)
hold on
plot(x(locs), pks, '^r')
for k1 = 1:size(pks,1)
plot(x, gausfcn(Parms(:,k1),x), 'LineWidth',1)
end
hold off
grid
The plot:

댓글 수: 7
camila
2016년 7월 13일
Hi, Thank you for your answer. It worked well. When I looked at the fit it is clear that I need to add baseline correction to the fit to get the correct area. I tried some syntacs available in the internet but was not succeeded. Could you please tell be how to add the baseline correction to this file.
Thanks you
Star Strider
2016년 7월 13일
My pleasure.
I would use the detrend function first for baseline correction. If that doesn’t work satisfactorily, we can try other approaches, including a highpass or bandpass filter. (Those require the Signal Processing Toolbox, but are fairly easy to implement.)
Eric Patterson
2018년 7월 24일
How can you determine what parameters you have put in place for the idxrng variable. I am having trouble completely fitting the curve under the peak with this code.
I’m guessing that you’re referring to the ‘25’ values.
I would tweak the code to something like this:
lims = 25; % Put This Before The Loop
then in the loop:
idxrng = locs(k1)-lims : locs(k1)+lims;
and experiment with the value of ‘lims’ to get the result you want. (My code was designed for this specific Question. It wasn’t intended to generalise automatically to every situation.)
Matin Salehi
2019년 8월 23일
Can you help me regarding a problem like this. I have a 28649x750 data, which are the intensity that is recorded by spectrometer.
each column has 310 peaks that I am interested on it (750x310). I could find the peaks, but now I want to know the the area under each peak. I also have the width, height and location of the peaks.
can you help me how can I write that.
Thor
2021년 2월 20일
Hi star strider, could you please define the meaning of lims? I have tried to applied your code to my data. However, the error " Array indices must be positive integers or logical values." appears. Many thanks @Star Strider
Star Strider
2021년 2월 21일
The ‘lims’ constant simply defines the range (±frame length) of ‘idxrng’.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Descriptive Statistics에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
