Why doesn´t my mesh-function plot a correct surface?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Joonas
le 15 Fév 2014
Réponse apportée : the cyclist
le 15 Fév 2014
Hello,
I´m wondering why my Matlab doesn´t plot me a correct surface compared to the surface that Wolframalpha gives me?
Both are trying to show a surface z = x^2+y^3.
Here´s my script in Matlab:
x=linspace(-1,1);
y=linspace(-1,1);
[x,y] = meshgrid(x,y);
z = (x.^2)*(y.^3);
mesh(x,y,z)
Wolframalpha plots me this kind of surface (Please, copy the address because the hyperlink tool didn´t work) : http://www.wolframalpha.com/input/?i=z+%3D+%28x%5E2%29*%28y%5E3%29
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156787/image.png)
Matlab plots me this kind of surface:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/156788/image.png)
What´s wrong with my Matlab?
Thank in advance!
0 commentaires
Réponse acceptée
the cyclist
le 15 Fév 2014
One tiny syntax error. Use this:
z = (x.^2).*(y.^3);
Note the dot before the *, so that you do element-by-element multiplication rather than matrix multiplication.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!