フィルターのクリア

Area under curves with different length (trapz)

3 ビュー (過去 30 日間)
mael thevenot
mael thevenot 2018 年 9 月 17 日
回答済み: Fabio Freschi 2019 年 12 月 4 日
Hi,
I'm trying to use the trapz command on MatLab R2015b.
I have 2 waves of data : y1(1x1036 double) and y2(1x9958 double) with different acquisition time, and I want to compare the area under both curves. But since the second wave have way more points I found a value much higher that did not make sense.
How can I do to tell the trapz function to take one value out of 10 for exemple? I've tried messing with the X parameter in
trapz(X, Y)
but I did not manage to make it work.
Thanks
  1 件のコメント
Fabio Freschi
Fabio Freschi 2019 年 12 月 4 日
Do you know the x axis for both waves?

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

採用された回答

Fabio Freschi
Fabio Freschi 2019 年 12 月 4 日
If you have the x axes for both waves, it is pretty easy to use trapz:
N1 = 1036;
N2 = 9958;
% wave 1
x1 = linspace(0,2*pi,N1);
y1 = sin(x1);;
% wave 2
x2 = linspace(0,2*pi,N2);
y2 = sin(x2);
% integrals
I1 = trapz(x1,y1)
I2 = trapz(x2,y2)
Both values are very close to 0, in line with the theory

その他の回答 (0 件)

カテゴリ

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