Convert the polar coordinates to rectangular coordinates, and plot the image as a surface, seen directly from above. Simple! And fast.

Here is a little example code that illustrates this approach:

%% ---------------------------- %%

close all

clear all

%% Create an example image using peaks function

im = peaks(512);

%% Specify axes for the image (chosen arbitrarily)

[nZ,nX] = size(im);

theta = ((0:(nX-1))-nX/2)*(0.1*(pi/180)) - pi/2;

rr = (0:(nZ-1))*0.1e-3 + 0.05;

%% Plot image in rectangular coordinates

figure

imagesc(theta*(180/pi), rr*1e3, im)

xlabel('theta [deg]')

ylabel('r [mm]')

%% Create grids and convert polar coordinates to rectangular

[THETA,RR] = meshgrid(theta,rr);

[XX,YY] = pol2cart(THETA,RR);

%% Plot as surface, viewed from above

figure

surf(XX*1e3,YY*1e3,im,'edgecolor','none')

view(0,90)

xlabel('x [mm]')

ylabel('y [mm]')

%% ---------------------------- %%

The code outputs two images, one of the polar plot made using the imagesc command:

... and one with the "proper" polar plot using surf:

## 5 comments:

This is great. It adapted very nicely to plotting the surface velocities of a circular tank. Nicely done. Thanks.

Great example. Works great with radar data. Thanks

Thank you Sir....It was a great help

Thank you, it's useful. But I can't understand why it plots only (1:nX-1,1:nZ-1) array, without last column and string. So I simply add one extra column and string to the data I want to plot.

Thanks!

## Post a Comment