Undefined function or variable 'e'
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am writing a code to convert 3D plot in to 2D plot for the given function. The code is as below
f=input('Enter any function in x and y f(x,y)=');
[x,y]=meshgrid (-10:0.5:10,-10:0.5:10);
figure
surf(x,y,f(x,y))
xlim([-11,11])
ylim([-11,11])
figure
surf(x,y,f(x,y))
view(90,0), shading interp
xlabel X, ylabel Y, zlabel Z
The code is sucessfully displays the results for @(x,y) sin(x.^2 + y.^2) & @(x,y) cos(x.^2 )*( y.^2), But for input like @(x,y)e^(-x.^2-y.^2)*(x.^2+y.^2) (I wish to check plots for exp(-x^2 -y^2) (x^2 +y^2)), it shows the error like "Undefined function or variable 'e'"
Please help me to sort out the error.
2 commentaires
Stephen23
le 9 Fév 2023
"Please help me to sort out the error."
Either define e or use the EXP() function:
Réponse acceptée
Torsten
le 9 Fév 2023
@(x,y)exp(-(x.^2 +y.^2)).* (x.^2 +y.^2)
instead of
@(x,y)e^(-x.^2-y.^2)*(x.^2+y.^2)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!