MATLAB: Numerical integration while keeping the parameters

integrationnumericalparametersplotting

I have a function which is like f(a,b,x). I want to numerically integrate it with respect to x, for example using quad function and plot the result of integration with respect to parameters a and b. Can someone share how can I achieve this?

Best Answer

Or, if it's actually a function of x with two parameters, and integrated over a fixed interval, then a variation of Andrew's answer will do it
f = @(x,a,b) sin(a*x+b);
x1 = 0;
x2 = pi;
[a,b] = meshgrid(-1:0.1:1);
z = zeros(size(a));
for k = 1:numel(a)
g = @(x) f(x,a(k),b(k));
z(k) = quad(g,x1,x2);
end
surf(a,b,z)