Area under curve using trapz

71 visualizaciones (últimos 30 días)
Kyle Henderson
Kyle Henderson el 30 de Jul. de 2019
Respondida: Priyanshu Mishra el 2 de Ag. de 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 comentarios
Andy
Andy el 30 de Jul. de 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 el 30 de Jul. de 2019
WME please.

Iniciar sesión para comentar.

Respuestas (1)

Priyanshu Mishra
Priyanshu Mishra el 2 de Ag. de 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);

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by