Plotting a rectangular matrix into a circle

658 views Asked by At

I have generated a rectangular matrix with the azimouth angle changing with rows and the radius changing as you change column. These are meant to represent the relative velocities experienced by a rotating helicopter blade. This produces a matrix called Vmat. I want to plot this to appears in a circle (representing the rotation of the blade)

So far I have tried

[R,T] = meshgrid(r,az);      

[x,y] = pol2cart(T,R);      

surf(x,y,Vmat(r,az));      

which should produce a contoured surface showing velocity as it changes with azimouth angle and radius but it comes up with dimension errors. I don't mind if it is a 2d contour plot or 3d plot i guess both would be written in a similar way.

Thanks James

1

There are 1 answers

4
nkjt On

The error is in writing Vmat(r,az), presuming that these are actual values of radius and azimuth, not indexes into your radius and azimuth. If you want to take only a subset of Vmat that's a slightly different matter, but this should work:

[R,T] = meshgrid(r,az);  % creates a grid in polar coordinates   
[x,y] = pol2cart(T,R);   % changes those to cartesian for surf
surf(x,y,Vmat);      

Alternatively you could do a contour plot:

h = polar([0 2*pi], [0 max(r)]); % set up polar axes with right scale
delete(h) % remove line
hold on
contour(x,y,Vmat);