I do not know why this is not plotting the multivariable function correctly?

It do not know why MATLAB plots incorrectly the following function f(x,y) = x*(10y+3)*e^(-x^2-y^2)
This is the code I wrote:
x = -5:0.1:5;
y = -5:0.1:5;
[X,Y]=meshgrid(x);
syms x y;
f(x,y) = exp(-x.^2)*exp(-y.^2)*x*(10*y+3);
F = X*(10*Y+3)*(exp(-X.^2-Y.^2));
surf(X,Y,F);
f = (exp(-x.^2-y.^2))*(10*y*x+3*x); % This is not part of the question
set(gca,'FontSize',15)
xlabel('$x$','FontSize',20,'interpreter','latex');
ylabel('$y$','FontSize',20,'interpreter','latex');
title('$x*(10*y+3)*exp(-x^2-y^2)$','FontSize',15,'interpreter','latex');
And this is the output I got
Any ideas?

 採用された回答

Torsten
Torsten 2022 年 3 月 22 日
F = X.*(10*Y+3).*(exp(-X.^2-Y.^2));
instead of
F = X*(10*Y+3)*(exp(-X.^2-Y.^2));

1 件のコメント

GUILLERMO REY PANIAGUA
GUILLERMO REY PANIAGUA 2022 年 3 月 22 日
Thank you very much! You saved my life! Now I got the right plot!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by