How to draw a polar graph from r=0?

Hi, The following code draws the polar graph in the attachment. The problem is that this graph should begin at r=0, whereas it doesn't. I was told that I probably need to condition the data prior to plotting, yet there is no dependence on r in the function and anyhow I'm not sure how to go about it. I'd appreciate some guidance.
MagE=((cos((5*pi/4)*cos(theta*pi))-cos(5*pi/4))./sin(theta*pi)).^2;
MagEdB = 10*log10(MagE);
MagEdB = MagEdB - max(MagEdB);
MagEdB(MagEdB<-40) = -40;
h = polarplot(theta*pi,MagEdB+40,'Linewidth',3,'color',[.21 .81 .94]);

1 Commento

Hello Yuval, Misha's answer below should solve your question, but I hope you don't mind a comment on the plots you have been doing.
I think there is a better way to go than plotting shifted data MagEdb+40 and then using a deliberately shifted grid to compensate, which is the
RTickLabel = {'-40','-30','-20','-10','0'}
approach from your question of 12 hours or so ago. Plotting the actual data MagEdb followed by
rlim([-40 0])
seems simpler and less error prone. (Your code above does not produce the plot above since the grid shift part is missing).
p.s. it works, but your choice of the variable to call theta seems a bit unconventional.

Accedi per commentare.

 Risposta accettata

Yuval, looks like you only need to increase the number of data points (theta):
theta = 0:0.001:2*pi;
or something like this.

3 Commenti

Hi, Thank you very much. Below is my code, which unfortunately still doesn't work despite tweaking theta as suggested. Theta has been changed back to produce the graph in the attachment:
theta=transpose(-1:0.01:1);
MagE=((cos((5*pi/4)*cos(theta*pi))-cos(5*pi/4))./sin(theta*pi)).^2;
MagEdB = 10*log10(MagE);
MagEdB = MagEdB - max(MagEdB);
MagEdB(MagEdB<-30) = -30;
h = polarplot(theta*pi,MagEdB,'Linewidth',3,'color',[.21 .81 .94]);
haxes = get(h,'Parent');
rlim([-40 0])
haxes = gca;
haxes.GridColor = 'k';
haxes.FontWeight = 'bold';
haxes.FontSize = 14;
haxes.LineWidth = 1.5;
haxes.ThetaZeroLocation = 'top';
haxes.ThetaTickLabel = {'0°','30°','60°','90°', '120°','150°','180°', '150°', '120°', '90°', '60°', '30°'};
Well, after computing MagEdB for the first time you keep manipulating this term including
MagEdB(MagEdB<-30) = -30;
which cuts off all values below.
Why not use
theta = transpose(-1:0.001:1);
...
mylim = -40;
MagEdB(MagEdB<mylim) = mylim;
...
rlim([mylim 0])
Perfect! Thank you so much, Mischa! Just one last thing (hopefully :-)) - is there a way to change all the numbers in this plot to latex?

Accedi per commentare.

Più risposte (0)

Categorie

Tag

Richiesto:

il 2 Dic 2016

Commentato:

il 2 Dic 2016

Community Treasure Hunt

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

Start Hunting!

Translated by