trapz or integral which one is more accurate?

3 visualizaciones (últimos 30 días)
masoud avaznejad
masoud avaznejad el 23 de Ag. de 2020
Respondida: Alan Stevens el 23 de Ag. de 2020
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;

Respuesta aceptada

Alan Stevens
Alan Stevens el 23 de Ag. de 2020
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.

Más respuestas (0)

Categorías

Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by