very similar dataset and yet 'TRAPZ' function gives very different answers

조회 수: 2 (최근 30일)
Dear All,
I am kind of struggling to figure out why two sets of data - quantitatively very similar - gives very different answers when numerically integrated uisng 'TRAPZ' funciton; data is attached in the .xls document.
Any insights in this regard are highly appreciated!
Thanks in advance!
Regards,
KD

채택된 답변

John D'Errico
John D'Errico 2023년 8월 17일
편집: John D'Errico 2023년 8월 17일
"Very" different? "VERY"? Lets be serious.
xy1 = [1.43155281315397 0.00255865851191916
1.35675838019809 0.0145131910703132
1.27925136527898 0.063166446949049
1.19895069245412 0.210990679450789
1.1157710244529 0.540955972655767
1.02962188546981 1.06472307447546
0.940406331363923 1.60888586350091
0.848018802346465 1.86658100394464
0.752341384965735 1.66264882670706
0.653236684654374 1.13700864870653
0.550532598338051 0.596885427112396
0.443984551996628 0.240497869152622
0.333159864072945 0.0743572051584443
0.216939570864193 0.0176351499842711
0.0888515203255917 0.00320643723615615];
a1 = trapz(flip(xy1(:,1)),flip(xy1(:,2)))
a1 = 0.8602
xy2 = [1.3574514696438 0.00230062694421278
1.29605548980418 0.0132435702443471
1.23099970732201 0.0584912051989921
1.16214843460327 0.198236594379449
1.08935954807805 0.51564908418259
1.01248347607602 1.02957271312853
0.931361701492302 1.57808683823824
0.84582439298594 1.85693323865362
0.75568634779567 1.67746620095548
0.660739348290927 1.16327656092461
0.560735966899023 0.619215364238612
0.455349613170889 0.252967924578314
0.344052551344047 0.0792989196684651
0.22559115331588 0.0190697822153908
0.0930728988402219 0.00351835370743469];
a2 = trapz(flip(xy2(:,1)),flip(xy2(:,2)))
a2 = 0.8048
The difference is roughly 6.5%
100*(a1 - a2)/a1
ans = 6.4501
plot(xy1(:,1),xy1(:,2),'r-',xy2(:,1),xy2(:,2),'b-')
So around 6.5% difference in area. Why should that surprise you? This has nothing to do with the use of trapz. The two have a different area, and trapz tells you that.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by