MATLAB Answers


Integrate a 2D griddedInterpolant wrt one variable

Asked by Anna Thuenen on 17 Jul 2019
Latest activity Edited by Andrei Bobrov
on 2 Aug 2019
I would like to know how to integrate a 2D griddedInterpolant with respect to one variable.
I include an example:
[x,y] = ndgrid(-5:0.8:5);
z = x.^2 + y.^2;
F = griddedInterpolant(x,y,z);
integral(@(x) F(x,1),0,1)
The actual interpolant is from data and not availbe in a closed analytical form.
This produces an error. Is there a simple alternative?


As mentioned: This is an example. The actual goal is to integrate an interpolant of data.
I know, but the quality of the result depends on the denseness of points (x,y) where you can supply z(x,y).
Hi friends!
>> x = -5:0.8:5;
y = x';
z = x.^2 + y.^2;
F = griddedInterpolant({x,y},z,'spline');
ans =

Sign in to comment.

1 Answer

Answer by Sai Bhargav Avula on 2 Aug 2019

The integral function in MATLAB does Numerical Integration and is the approximate computation of an integral using numerical techniques. As mentioned by the @Torsten the quality depends on the denseness of points (x,y).


Sign in to comment.