Area under curve using trapz

69 views (last 30 days)
Kyle Henderson
Kyle Henderson on 30 Jul 2019
Answered: Priyanshu Mishra on 2 Aug 2019
Hello,
I am trying to calculate the area under the curve and partial area under the curve for a scalogram created from a wavelet. The scalograms x axis is logarithmic and the y axis is linear. The values I get when I attempt to run it do not make sense.
  2 Comments
Andy
Andy on 30 Jul 2019
Your question does not give enough information; What is the data you are using? What code are you using? What answers are you getting?

Sign in to comment.

Answers (1)

Priyanshu Mishra
Priyanshu Mishra on 2 Aug 2019
I am assuming that you have changed your X axis values in logarithmic scale and stored it in the new variable.
Now, use the function trapz to calculate the complete area under the curve where, variable ‘X’ should be logarithmic values.
For partial area under the curve, you can use the following sample code:
% let us assume that you want to calculate area in the range [5:15]
Index_begin= 5 ;
Index_end= 15;
X_new= x(Index_begin:Index_end); % x is contains all the values in X axis
Y_new= y(Index_begin:Index_end); % y contains all the values in Y axis
Partial_area = trapz(X_new,Y_new);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!