How to fix a function to get 2d integral
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello, I am trying to use the built in function integral2 to compute an area.
However, I am getting this warning 'Reached the maximum number of function evaluations (10000). The result fails the global error test.'
My function and the integral doesn't seem so difficult. The function is continuous. Does anyone have any ideas as to why this is happening?
Here is my code, the image generated at the bottom is just to give an idea of what the shape looks like.
a=-5.0;
c=-0.4;
e= 1.1;
L= 50;
fbonus = @(z) (1 - tanh(10.*(((2*abs(z))./L).^8)));
b0 = -8.0;
d0 = 0.2;
b = @(z) b0 .* fbonus(z);
d = @(z) d0 .* fbonus(z);
yfunc = @(x,z) real((a*sqrt(1-((x./b(z)).^2)) + (a/2) .* sqrt(1-((x./(2.*b(z))).^4)) + c .* exp(-abs(x)./d(z)) + e));
Q = integral2(yfunc,0,15,0,25)
Qtotal = Q .* 4;
y = zeros(37,51);
for i = 1:37;
x = i - 19;
for ii = 1:51
z = ii-26;
y(i,ii) = yfunc(x,z);
end
end
figure(1);
surf(-25:25, -18:18, y);
title('The Boat'); xlabel('length, z'); zlabel('depth,y')
ylabel('width,x')
colormap(spring);
Thank you for the help!
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Numerical Integration and Differentiation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!