Area under curve using trapz

67 ビュー (過去 30 日間)
Kyle Henderson
Kyle Henderson 2019 年 7 月 30 日
回答済み: Priyanshu Mishra 2019 年 8 月 2 日
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 件のコメント
Andy
Andy 2019 年 7 月 30 日
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 2019 年 7 月 30 日
WME please.

サインインしてコメントする。

回答 (1 件)

Priyanshu Mishra
Priyanshu Mishra 2019 年 8 月 2 日
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);

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by