# How do you create a surf plot in cylindrical coordinates?

157 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Jonathan Epperl
on 19 Nov 2012

Or even easier, remember that you're not forced to put just one variable X in the first argument of surf, all you need is a parametrization. So in your case, assume you have vectors r and phi. Then make them into a grid, obtain a matrix with z-values using your function F and just plot:

[R PHI] = meshgrid(r,phi);

Z = F(R,PHI); % which assumes your function is vectorized

surf(R.*cos(PHI), R.*sin(PHI), Z);

### More Answers (2)

Matt J
on 17 Nov 2012

##### 0 Comments

Teja Muppirala
on 19 Nov 2012

You can use POL2CART to convert the data from r/theta to x/y and then call SURF.

[R,TH] = ndgrid(0:0.1:5,linspace(0,2*pi,41));

F = @(r,th) sin(th).*sinc(1+r);

Z = F(R,TH);

[X,Y] = pol2cart(TH,R);

surf(X,Y,Z);

##### 0 Comments

### See Also

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!