MATLAB Answers

Sharah
0

Plotting radar plot in matlab like the one in excel

Asked by Sharah
on 13 May 2015
Latest activity Answered by Rohit Jain on 15 May 2015
hello, i have been looking around for ages about this. there's a function in excel where i can plot data in circle.
for example i have i have an arra
y of time and force. in excel, i can put the time (x axis in circle and the force will goes in circle.
i tried polar function, compass but it does not turn out like i want to. here's the picture i got from excel.
if you can see from the picture attached, time is written at the outer circle and the force value at each time internal will follow.
anyone?

  4 Comments

Show 1 older comment
I have tried the radar plot unfortunately it doesn't turn out like i want it to be. it seems easy to do it in excel, and it's a shame that i couldn't find a way to do it in matlab
The label seems to be linear indices so I'm curious what is the meaning of this plot. Is it scanning the space? Thanks.
There are similar plots available in MATLAB. You can try these and see if it matches your requirement. The plots which are similar to radar are 'polar','compass','rose'. See the documentation page to know more details about these plots. http://www.mathworks.com/help/matlab/ref/polar.html http://www.mathworks.com/help/matlab/ref/rose.html http://www.mathworks.com/help/matlab/ref/compass.html

Sign in to comment.

2 Answers

Answer by Star Strider
on 14 May 2015

I don’t know what data you’re plotting. See if this code can be adapted to do what you want:
th_x = [0 56
10 30
20 11
30 11
40 5
50 3
60 6
70 8
80 14
90 16
100 15
110 7
120 6
130 9
140 7
150 10
160 21
170 39
180 56
190 30
200 11
210 11
220 5
230 3
240 6
250 8
260 14
270 16
280 15
290 7
300 6
310 9
320 7
330 10
340 21
350 39];
xr = [repmat(th_x(:,2)', 10, 1); zeros(1,36)];
xr = [0 reshape(xr, 1, [])];
th = linspace(0, 359, length(xr));
I originally wrote this to be a ‘polar’ version of ‘bar’. The data ‘th_x’ has degrees in the first column and the values to be plotted in the second. It expands the data to span the 10-degree increments to produce the ‘rose’ plot effect.

  3 Comments

basically what i am trying to do is to plot the x axis in form of circle, where the start point and the end point will meet. the y value will be the same as in normal plot, but obviously it will follow the x axis shape (which is in circle)
do you get what i mean?
I sort of understand.
Can you attach your data (preferably as a .mat file) so I can experiment with it to see if I can reproduce the Excel plot in MATLAB?
so to add onto this you can adjust your x and y to be something like
t = 0 : .01 : 2 * pi;
P = polar(t, 15 * ones(size(t)));
set(P, 'Visible', 'off')
hold on
y = [1 1 1 1 1 1 1 10 10 10 10 10]
y = repmat(y,1,10);
x = 1:numel(y);
x = (360/numel(y)*x+90)*pi/180;
polar(x,y)
where the first one is just to "cheat" and scale the axis. The real issue right now is to change the axis labeling to be what x is actually. it's a difficult task as these are inserted text field and not adjustable using xlim and ylim. one would have to write something like
set(findall(gcf, 'String', '90') ,'String', num2str(0));
set(findall(gcf, 'String', '180') ,'String', num2str(round(numel(y)/4)));
which would then re-label polar label to what it would be in that slice. It would be feasible to wipe out all text labels and then write a loop to create and position txt labels in a circle around the polar plot area but i don't have the time to write it out. Maybe the file exchange has something to relabel polar plots and set tick spacing.

Sign in to comment.


Answer by Rohit Jain on 15 May 2015

There are similar plots available in MATLAB. You can try these and see if it matches your requirement. The plots which are similar to radar are 'polar','compass','rose'. See the documentation page to know more details about these plots. http://www.mathworks.com/help/matlab/ref/polar.html http://www.mathworks.com/help/matlab/ref/rose.html http://www.mathworks.com/help/matlab/ref/compass.html

  0 Comments

Sign in to comment.