Area under curve using trapz

68 visualizzazioni (ultimi 30 giorni)
Kyle Henderson
Kyle Henderson il 30 Lug 2019
Risposto: Priyanshu Mishra il 2 Ago 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 Commenti
Andy
Andy il 30 Lug 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?
Adam Danz
Adam Danz il 30 Lug 2019
WME please.

Accedi per commentare.

Risposte (1)

Priyanshu Mishra
Priyanshu Mishra il 2 Ago 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!

Translated by