I have 1024 X 256 polar data (rows - radius, columns angle) that I need to plot as an image. There is an m-file I got from the file-exchange that can do this (clickhere). However, it is really slow for large images. I believe there is a fast way to do this using the surf function that I am struggling with. (See code below)
data = data; % load any polar data
depth = 4.5; %imaging depth in mm
offset = 0.5;
theta = [(0:2*pi/size(data,2):2*pi-1/size(data,2))]*180/pi;
rho = [0:(depth-offset)/size(data,1):(depth-offset)-1/size(data,1)] + offset;
[THETA,RR] = meshgrid(theta,rho);
[A,B] = pol2cart(THETA,RR);
figure
surf(A,B,data,'edgecolor','none'),
view(0,90)
xlabel('x [mm]')
ylabel('y [mm]')
axis tight
The result appears to be incorrect.
Any idea what I am doing wrong? Thanks!
Yep, your problem is simple:
pol2cart Transform polar to Cartesian coordinates.
[X,Y] = pol2cart(TH,R) transforms corresponding elements of data
stored in polar coordinates (angle TH, radius R) to Cartesian
coordinates X,Y. The arrays TH and R must the same size (or
either can be scalar). ***TH must be in radians***.
Solution: Remove the 180/pi