From: MDP on 15 Feb 2010 05:47 Hi... I'm trying to plot a radiation pattern using the PolarPlot function, but need to use a dB scale for the magnitude. I would also like to have an angular lines and circles at defined increments. I've searched and couldn't find anything... Anyone know of a way to do this? Thanks Marc
From: Bob Hanlon on 16 Feb 2010 03:50 PolarPlot[Max[0, 10 Log10[1000*Sinc[3 t]^2]], {t, -Pi, Pi}, PolarAxes -> True, PolarGridLines -> { Table[t, {t, 0, 2 Pi, Pi/12}], Table[r, {r, 6, 36, 3}]}, PolarTicks -> { "Degrees", Table[r, {r, 6, 36, 6}]}, TicksStyle -> Blue, PlotStyle -> {Red, Thick}] Bob Hanlon ---- MDP <mparent(a)comcast.net> wrote: ============= Hi... I'm trying to plot a radiation pattern using the PolarPlot function, but need to use a dB scale for the magnitude. I would also like to have an angular lines and circles at defined increments. I've searched and couldn't find anything... Anyone know of a way to do this? Thanks Marc
From: dr DanW on 16 Feb 2010 03:50 Marc, Below is a .m file I created for doing polar patterns of hearing aid directionality. The scale for hearing aid directionality is set by a standard, so the limits are hard-coded; I did not try to make it general. The scale goes from +5 dB to -25 dB, with everything below -25dB truncated off. The standard also defines 0 degrees to be vertical on the page and azimuth increasing clockwise, so there are some functions to make this transformation which may not be necessary for you. Enjoy --- snip --- KEAxisColor::"usage"="KEAxisColor is the color I like for axes."; KEAxisColor=RGBColor[112./255,120./255,68./255]; microphonePolarGrid=Module[{a,xy}, a=Range[0,330,30]; xy={Sin[#],Cos[#]}&/@(a Degree); Flatten[{ KEAxisColor, Line[{{-1,0},{1,0}}],Line[{{0,-1},{0,1}}], Circle[{0,0},#]&/@{10,15,20,30}, Line[{5#,30#}]&/@xy, Black, Circle[{0,0},25], MapThread[Text[ToString[#1]<>"\[Degree]",32.5#2]&,{a,xy},1], Text[Framed[ToString[#]<>" dB",FrameStyle->White,FrameMargins- >1,Background->GrayLevel[.99]],{4,(#+25)}]&/@Range[-20,5,5] }] ]; originLimit=Function[v,If[v<-25,0,v+25],Listable]; PolarPatternFunction::"usage"="PolarPatternFunction[ \!\(\* StyleBox[\"fnc\",\nFontSlant->\"Italic\"]\) ] accepts a linear polar response function \!\(\* StyleBox[\"fnc\",\nFontSlant->\"Italic\"]\) as a function of theta in radians, and returns the polar pattern function in dB re \!\(\* StyleBox[\"fnc\",\nFontSlant->\"Italic\"]\)[0] as a function of azimuth in degrees."; PolarPatternFunction[prf_,th_Symbol]:=Function[az,Evaluate[ N[20Log[10,Abs[(prf/.th->(360-az)Degree)/(prf/.th->0)]]] ] ] PolarPatternFunction[prf_]:=Function[az,Evaluate[ N[20Log[10,Abs[prf[(360-az)Degree]/prf[0]]]] ] ] MicrophonePolarPlot::"usage"="MicrophonePolarPlot[ ppf, {az, min, max} ] plots the polar pattern function as a function of azimuth az from min to max. \n\n Note that polar pattern must be normalized for it to display correctly on the grid. Functions created by PolarPatternFunction are normalized."; Options[MicrophonePolarPlot]:=Options[PolarPlot]; MicrophonePolarPlot[pp_,{azs_,azmin_,azmax_},opts:OptionsPattern[]]:= PolarPlot[ Evaluate[Sequence@@Module[{q},{ originLimit[pp]/.azs->(\[Pi]/2.-q)/ Degree,{q,\[Pi]/2-azmax Degree,\ [Pi]/2-azmin Degree}}]], opts, AspectRatio->1, PlotStyle->Thick, PlotRange->{{-35,35},{-35,35}}, Axes->False, ImageSize->Medium, Prolog->microphonePolarGrid ] AzimuthToTheta::"usage"="AzimuthToTheta[ az ] converts azimuth to theta. A convenience when generating simulated data from a polar response function, as in 20*Log[10, Abs[R[AzimuthToTheta[az]]]]"; AzimuthToTheta[az_]:=(360-az)Degree NormalizePolarData::"usage"="NormalizePolarData[ dat ] normalizes dat, a data set in the format { {azimuth, dB}, .. } to the value of the first data point, assumed to be azimuth = 0. Pass a second argument to normalize to that value."; NormalizePolarData[dat_,ref_:Automatic]:=Module[{r}, r=If[ref===Automatic,dat[[1,2]],ref]; {#[[1]],#[[2]]-r}&/@dat ] ListMicrophonePolarPlot::"usage"="ListMicrophonePolarPlot[ ppd ] plots polar pattern data in the format { {azimuth, dB}, .. }. \n\n Note that polar pattern data must be normalized for it to display correctly on the grid. Use NormalizePolarData to do so."; ---end code---
|
Pages: 1 Prev: need help determined time to travel a path Next: can't get ListVectorPlot3D to work. |