MATLAB: Polarplot in dB.

polarplot

Hi, I am trying to plot a certain function (traveling wave) using polarplot(). However, the result isn't even close to that presented in the attachment, which is supposed to be the polar plot of the very same function! I have been trying for two days now to figure out what might be causing this visual discrepancy, to no avail. Below is my calling of polarplot:
theta=transpose(-1:0.01:1);
MagE=(cot(theta*pi/2).^2).*(sin(5*pi*(cos(theta*pi)-1))).^2;
polarplot(theta*pi,MagE,'Linewidth',1,'color',[.21 .81 .94]);
I also tried changing MagE to db(MagE), as the plot in the attachment appears to be in dB, yet it didn't do the trick. I hope someone here might be able to suggest a solution. I'd appreciate any assistance, advice, promptly if possible. Thanks
in advance.

Best Answer

You need to be careful about dB values as they might be negative. So you need to preprocess it to make it all positive before plotting and then fix the labeling. Here is an example
MagEdB = 10*log10(MagE);
MagEdB = MagEdB - max(MagEdB);
MagEdB(MagEdB<-40) = -40;
h = polarplot(theta*pi,MagEdB+40,'Linewidth',1,'color',[.21 .81 .94]);
haxes = get(h,'Parent');
haxes.RTickLabel = {'-40','-30','-20','-10','0'};
HTH