My code has an opstruct error. What does it mean and how to solve it?
Afficher commentaires plus anciens
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;
Réponse acceptée
Plus de réponses (1)
Mr. Pavl M.
le 27 Oct 2024
Modifié(e) : Mr. Pavl M.
le 27 Oct 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;
Catégories
En savoir plus sur Language Fundamentals dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


