フィルターのクリア

Integration over different sampling rates

18 ビュー (過去 30 日間)
Kyle
Kyle 2024 年 7 月 17 日 12:04
回答済み: sai charan sampara 2024 年 7 月 17 日 12:20
I have 2 graphs ploted over the same duration of 20ms. I am looking to take the integral of the positive region of each. Their sampling rate is different by a factor of 4x. The blue line sampled at 800000 and the orange at 200000. Using the trapz function on the 1D curves I am getting a drastic difference in the data sets. I am a bit confused by this because the span the same normalized distance so I assumed that the blue one would just take then same area but divide it more leading to roughly the same output. But my outputs are wildly differenet and I am looking to understand why.
Attached is the image of the graphed curves and the data trends. For the sake of use the full data array can be used for explination as it will hold true.

採用された回答

sai charan sampara
sai charan sampara 2024 年 7 月 17 日 12:20
Hello Kyle,
You can get the correct value for the area by giving the time vector also to the "trapz" function. It gives the integral the second dimension over which the area can be calculated.The following code might help you:
load ratline.mat
load FerretLine.mat
t1=linspace(0,20e-3,length(staticRat));
t2=linspace(0,20e-3,length(Ferret))';
plot(t1,staticRat)
hold on
plot(t2,Ferret)
hold off
trapz(t1,staticRat)
ans = 0.0201
trapz(t2,Ferret)
ans = 0.0153

その他の回答 (0 件)

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by