Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
m[x_, y_] := 
 0.9*Exp[-((x - 1)^2 + (y - 1)^2)] + 
  0.5 Exp[-(3^2 ((x - 2.5)^2 + (y - 1.5)^2))]

I'm trying to create a 3d plot for the function above. I tried Plot3D, but all i got was a blank. my plot attempt : Plot3D[m, {x, -1, 1}, {y, -1, 1}]

share|improve this question

closed as off-topic by Nasser, Rahul Narain, Michael E2, bobthechemist, m_goldberg Jul 6 at 3:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Nasser, Rahul Narain, Michael E2, bobthechemist, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
You can't just write Plot3D[m,...] you have to actually call m with the arguments. Try m[x,y] –  Nasser Jul 6 at 1:21
    
oh and i made a mistake, the domain is x= 0 to 5, y = 0 to 5 –  Lebouski Jul 6 at 1:22
1  
Ok, you can try Plot3D[m[x, y], {x, 0, 5}, {y, 0, 5}, PlotRange -> All] and see if this works –  Nasser Jul 6 at 1:23
    
It does! sorry I'm not too familiar with mathematica. thanks for the quick reply. –  Lebouski Jul 6 at 1:25
    
I was going to down-vote this since it would seem to be a very simple error that would be avoided by just looking at the documentation for Plot3D. Turns out, though, that it's not so easy to find an example in the documentation like this, where first one defines the function of two variables and then plots it. (The first example there of this kind is, in fact, much more complicated: NDSolve[{D[u[t, x], t] == D[u[t, x], x, x], u[0, x] == 0, u[t, 0] == Sin[t], u[t, 5] == 0}, u, {t, 0, 10}, {x, 0, 5}] followed by what is essentially Plot3D[Evaluate[u[t, x] /. %], {t, 0, 10}, {x, 0, 5}]. –  murray Jul 6 at 3:02

1 Answer 1

up vote 1 down vote accepted

you don't need to use m[x_,y_]:= simply as follow:

m = 0.9*Exp[-((x - 1)^2 + (y - 1)^2)] + 
   0.5 Exp[-(3^2 ((x - 2.5)^2 + (y - 1.5)^2))];
Plot3D[m,{x, 0, 5}, {y, 0, 5}, PlotRange -> All]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.