trapz or integral which one is more accurate?

3 次查看(过去 30 天)
clc
clear
close all
x = linspace(0,100);
y = x.^cos(x);
plot(x,y);
a = trapz(x,y);
y = @(x)x.^cos(x);
b = integral(y,0,100);
c=a-b;

采纳的回答

Alan Stevens
Alan Stevens 2020-8-23
integral is more accurate here. Try
x = linspace(0,100,1000);
and you will find the trapz result reduces to get much closer to the integral result.

更多回答(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