Am I writing this exponential function the right way?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I just got into MATLAB and trying different things, right now I'm experimenting with 3D plots. I'm not sure if I'm writing this exponential function the right way.
My input looks following: z=x*exp((-x^2-y^2)); I'm not sure if I'm getting the right output with mesh(x,y,z), it looks different from what I expeted :)
Risposte (1)
John D'Errico
il 15 Nov 2022
Modificato: John D'Errico
il 15 Nov 2022
You need to learn about the dotted operators. They are used when you will be performing ELEMENT-wise squaring, multiplications, and powers.
z=x.*exp((-x.^2-y.^2));
There are no dotted adds or subtracts. But the regular * / and ^ operators do something different when you have matrices. The two sets of operators are the same for scalars, so when you first learned MATLAB, you saw no problems. But matrices (and vectors) are different animals.
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!