How can I make a cartesian graph into a polar graph?

I have a 16x9 array, of which the last 8 columns are 1x37 matrices (for angles 0:5:180), so the end goal is to get 16 different graphs.
The last 6 columns were calculated by me, in radians. The columns 2 and 3 were read from a file, in degrees, so I convert those to radians and then try to plot them together, against the x value shown.
figure(1)
hold on
for i=0:5:180
x((i/5)+1)=(i*pi)/180;
end
for i=1:length(DataAll)
for j=2:3
DataAll{i,j}=DataAll{i,j}*pi/180;
end
end
for i=2:9
polarplot(x,DataAll{1,i});
end
Hopefully this is enough information to go on, if not I can provide more.

6 Comments

x=deg2rad(0:5:180);
will replace the first loop.
I can't follow the 16x9 with 8 vectors; show us a sample subset.
You say you have data for the 0:5:180 angles but you need an r value to plot against and you seem to think those are angles, too? That doesn't seem to make any sense (unless the measured data are some tracking to a target of a device or something???).
In the end, you really didn't ask a question...does this do what you expect and if not, what did you get and what were you expecting?
This is the error I keep receiving:
Adding polar plot to Cartesian axes is not supported
And I was wondering how I can fix it.
{3×3 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double}
{3×3 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double}
{3×3 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double}
{3×3 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double} {1×37 double}
Above is the the cell array, the first column isn't being plotted and the 9th column is the same as 2 through 8.
The 1x37 is a matrix is an angle dependent calculated value corresponding to each degree, starting from 0 to 180 in increments of 5.
So I would like my theta to be the x from above, and the r values are the values within the 1x37 matrix.
The plotting works just fine in cartesian coordinates, resulting in this.
A polar axes object created by polarplot is unique and can't be mixed with other plot functions.
You could use two overlaying axes a la plotyy trick or you might be able to revert to the old polar which still uses a conventional axes; I've never tried that.
" theta to be the x from above, and the r values are the values within the 1x37"
So the idea is 16 figures with 8 lines on each?
How about attaching a .mat file with the data array for folks to play at...the polarplot is a pretty new beastie...
Finally figured it out, it had nothing to do with the array itself. Instead it was the 'hold on' at the beginning, even though there was no previous graphs or axis for it to hold, so it was creating a figure with Cartesian axis on it.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2018a

Asked:

on 12 Jul 2018

Commented:

on 13 Jul 2018

Community Treasure Hunt

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

Start Hunting!