Sum of both negative - positive part of a Peak
    7 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    abaza
 am 25 Nov. 2019
  
    
    
    
    
    Bearbeitet: Star Strider
      
      
 am 25 Nov. 2019
            Dear ALL,
I have a peak that I woud like to take the integral of it, however, this peak has a positive (> 0 baseline) and negative part (< 0 beaseline).
So, is it any function in MATLAB that automatically sums both parts? 
Please see attached the example...

0 Kommentare
Akzeptierte Antwort
  Star Strider
      
      
 am 25 Nov. 2019
        Try this: 
x = linspace(6.622, 9.644);
y = exp(-(x-mean(x)).^2/0.5) - 0.1;
Lv = y>=0;
PosPart = trapz(x(Lv), y(Lv))
NegPart = trapz(x(~Lv), y(~Lv))
SumParts = PosPart - NegPart
figure
plot(x, y)
Experiment to get different results.  
2 Kommentare
  Star Strider
      
      
 am 25 Nov. 2019
				
      Bearbeitet: Star Strider
      
      
 am 25 Nov. 2019
  
			My pleasure!  
EDIT — (25 Nov 2019 at 22:10)
Depending on what you want to do, this may be more accurate: 
Lv = y>=0;
PosPart = trapz(x(Lv), y(Lv))
LT0 = trapz(x(~Lv), ones(size(x(~Lv)))*min(y))
NegPart = LT0 - trapz(x(~Lv), y(~Lv))
SumParts = PosPart - NegPart
Weitere Antworten (1)
  Image Analyst
      
      
 am 25 Nov. 2019
        What if you sum the absolute value of the signal?
area = sum(abs(signal));
That will be the difference between the signal and the y axis.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


