Borrar filtros
Borrar filtros

Polarplot in dB.

44 visualizaciones (últimos 30 días)
Yuval
Yuval el 1 de Dic. de 2016
Comentada: Honglei Chen el 2 de Dic. de 2016
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.

Respuesta aceptada

Honglei Chen
Honglei Chen el 1 de Dic. de 2016
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
  4 comentarios
Honglei Chen
Honglei Chen el 1 de Dic. de 2016
BTW, another possibility is your data. If you look at your original MagE, the value in the middle is NaN, it's probably because you have a 0/0, but there is a valid limit value for that point. You may need to condition your data first.
HTH
Honglei Chen
Honglei Chen el 2 de Dic. de 2016
Looking at your equation, when theta is 0, you know that the function should give you the value of 0 when it approaches 0. However, because the way you construct your function, when MATLAB evaluates it, it notices that it is inf*0, so it gives you an NaN (Think for example the case of sin(x)/x). Therefore, you need to identify those cases yourself before you plot so it does not try to plot NaN, which is a gap.
For example, in your original, there is a gap at theta==0. If I do the adjustment before plotting, then it works just fine.
MagE(theta==0) = 0; % <- preconditioning
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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Polar Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by