How to integrate the area below the peak when I dont have function of the peak?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sanjay Krishnamurthy
am 23 Mär. 2022
Kommentiert: sanjay Krishnamurthy
am 23 Mär. 2022
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/938209/image.jpeg)
% Integrate area below the peak
plot(AR_T,AR_mwmg) %AR_T and AR_mwmg are data stored in AR_data.mat file
int_AR = trapz(AR_T,AR_mwmg)
Akzeptierte Antwort
AndresVar
am 23 Mär. 2022
Bearbeitet: AndresVar
am 23 Mär. 2022
Use conditional indexing to define the limits of extent for the peak.
clear
load("AR_data.mat")
% remove nan values (why is there a nan at the end?)
idxNotNan = ~isnan(AR_T) & ~isnan(AR_mwmg);
x = AR_T(idxNotNan);
y = AR_mwmg(idxNotNan);
%findpeaks(y,x,'Annotate','extents','WidthReference','halfheight','NPeaks',1,'SortStr','descend');
%[pkY, pkX, pkWidth, pkProm]=findpeaks(y,x,'NPeaks',1,'SortStr','descend')
idxPk = x>210 & x<325; % more or less...
xPk = x(idxPk);
yPk = y(idxPk);
figure;
plot(x,y,LineWidth=2,DisplayName='data')
hold on;
plot(xPk,yPk,'--',LineWidth=2,DisplayName='peak')
legend('show');
AreaFull=trapz(x,y)
AreaPk=trapz(xPk,yPk)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!