Matlab integral not giving right result as trapz function
Show older comments
I have the following code
x = 0:0.1:1;
y = x.*x;
dy = gradient(y);
dx = gradient(x);
dx_fun = @(z) spline(x,dx,z);
dy_fun = @(z) spline(x,dy,z);
integral(dy_fun,0,1)
trapz(dy_fun(x))
the result obtained by the integral function does not match the result obtained by trapz function. Both bounds of the intergation are the same for both function. Value of trapz(dy_fun(x)) = y(end,1)
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!