I am trying to find the area as a part of a graph(Area-A and Area-B in the picture below). However, when I am using "trapz" function, it is not giving any output. Code is mentioned below and .mat file is attached. Please help me out.
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161628/image.jpeg)
clc;
a=importdata('anirban normal.mat');
b=a.data;
x=b(22810:25750,1);
figure();
plot(x);
Area=trapz(1:694);
x(x<0)=[];
findpeaks(x);
findpeaks(x,'MinPeakHeight',0.927);*
采纳的回答
KSSV
2017-3-13
编辑:KSSV
2017-3-13
a=importdata('anirban normal.mat');
b=a.data;
x=b(22810:25750,1);
figure();
plot(x);
% Area=trapz(1:694);
id = 1:length(x) ;
% Int = trapz(id,x) ;
% x(x<0)=[];
% findpeaks(x);
% findpeaks(x,'MinPeakHeight',0.927);
[val,maxid] = max(x) ;
Area1 = trapz(id(1:maxid),x(1:maxid)) ;
Area2 = trapz(id(maxid:end),x(maxid:end)) ;
Area = trapz(id,x) ;
Check Area = Area1+Area2
3 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!