Here are a couple of things I see wrong with the equation:
- There is a missing close parentheses somewhere in your equation, perhaps after the first
sqrt(x.^2+y.^2)
? In the equation, it appears that you are dividing sqrt(x.^2+y.^2)
by itself, which is probably not what you want to do and is why I was thinking you were missing a parentheses from around there.
- You will probably want to perform element-wise division using
./
instead of matrix right division using /
(see this link for more detail).
In addition, you will want to change the 'FaceColor'
property of the surface object to 'none'
so that only the edges of the mesh are displayed:
[x,y] = meshgrid(-1:.1:1,-1:.1:1);
z = ... %# Compute your z in some way
surf(x,y,z,'FaceColor','none');