My code has an opstruct error. What does it mean and how to solve it?
Mostrar comentarios más antiguos
clc
clear all
f = @(x, y) exp(-(x.^2 + y.^2));
x_min = 0;
x_max = 1;
y_min = @(x) 0;
y_max = @(x) -sqrt(1 - x.^2);
result = integral2(f, x_min, x_max, y_min, y_max);
fprintf('The result of the integral is:', result);
fsurf(@(x, y) exp(-(x.^2 + y.^2)), [0 1 -1 0], 'EdgeColor', 'none');
grid on;
Respuesta aceptada
Más respuestas (1)
Mr. Pavl M.
el 27 de Oct. de 2024
Editada: Mr. Pavl M.
el 27 de Oct. de 2024
format long
clc
clear all
f = @(x,y)exp(-(x.^2+y.^2));
x_min = 0;
x_max = 1;
y_min = 0 ;% it already matched w/o too much text
% better than later proposed @(x) zeros(size(x)), because x_min, x_max are floating point scalars;
y_max = @(x)-sqrt(1-x.^2);
result = integral2(f,x_min,x_max,y_min,y_max,'Method','auto','AbsTol',0,'RelTol',1e-12);
fprintf('The result of the integral is:');
disp(result)
fsurf(@(x,y) exp(-(x.^2+y.^2)),[0 1 0 1],'EdgeColor','green');
title('Original 1st Solution')
xlabel('x')
ylabel('y')
zlabel('f')
grid on;
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


