Joe
Joe

Reputation: 65

How to do mesh plot in MATLAB?

I am trying to make a plot like this:-
enter image description here

I can use this formula to plot it : NearField = r^2/l
‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ where ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ r = the radius of the transducer
‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ and ‍‍‍‍‍‍ ‍‍‍‍‍‍ ‍‍‍‍‍‍ l = the ultrasound wavelength

Here is my code :

colormap(hsv);
l=0.0001:0.00015:0.0015;
r=0.001:0.001:0.01; 
[x,y]=meshgrid(r,l);
nearField = x.^2/y;
mesh(r,l,nearField)

When I plot it, I get the following :

enter image description here

Why do I not get the plot like in first figure?

Upvotes: 1

Views: 117

Answers (2)

OSES_help
OSES_help

Reputation: 5

I think you should not use mesh in the bottom line. Plot3 or surf commands should do want you want (the first one draws lines, the second one draws a surface). I hope it was helpful.

Upvotes: 0

H. Kaspari
H. Kaspari

Reputation: 21

You used the wrong coordinates. The first seems to use polar coordinates instead of x,y. Also your r is called radius, which means that r²=x²+y². You have to transform the formular in x,y coordinates to use mesh. I don't think, that there is a matlab function which does this automatically :/

Upvotes: 2

Related Questions