X-Git-Url: http://gitweb.scilab.org/?p=scilab.git;a=blobdiff_plain;f=scilab%2Fmodules%2Fcacsd%2Fmacros%2Fnicholschart.sci;h=69c972a424bbc1a8420cf6ef3c73fe2ad3e1bed4;hp=4ab1a89e4c33c322fd73fff9391adc06a688405a;hb=e240cb72211860c65493168c33464c1f5656f4b1;hpb=83cc90cfd13a7115b914289f976fa325fc2da862 diff --git a/scilab/modules/cacsd/macros/nicholschart.sci b/scilab/modules/cacsd/macros/nicholschart.sci index 4ab1a89..69c972a 100644 --- a/scilab/modules/cacsd/macros/nicholschart.sci +++ b/scilab/modules/cacsd/macros/nicholschart.sci @@ -11,7 +11,10 @@ function nicholschart(modules,args,colors) l10=log(10); ratio=%pi/180; - drawlater() + fig=gcf(); + immediate_drawing=fig.immediate_drawing; + fig.immediate_drawing="off"; + ax=gca(); nc=size(ax.children,"*") if nc==0 then @@ -32,8 +35,8 @@ function nicholschart(modules,args,colors) mod_min=ax.data_bounds(1,2) mod_max=ax.data_bounds(2,2) - defaultArgs = [1 5 10 20 30 50 90 120 150 180] - defaultModules=[mod_min:20:-40 -12 -6 -3 -1 0 0.25 0.5 1 2.3 4 6 12]; + defaultArgs = [1 2 5 10 20 30 50 70 90 120 140 160 180]; + defaultModules=[mod_min:20:-35 -30 -25 -20 -15 -12 -9 -6 -3 -2 -1 -0.5 -0.25 -0.1 0 0.1 0.25 0.5 1 2.3 4 6 12]; if exists("modules","local")==0 then @@ -63,8 +66,8 @@ function nicholschart(modules,args,colors) colors=colors*ones(1,2) end end - // convert args to radian - args = -args * ratio; + // convert args to radian and insure negative + args = -abs(args) * ratio; //initialize handles array for chart entities chart_handles=[] @@ -139,12 +142,16 @@ function nicholschart(modules,args,colors) eps=10*%eps; for teta=args, + //w = teta produce a 0 gain and consequently a singularity in module if teta < -%pi/2 then last=teta-eps, else last=teta+eps, end; - w=[-170*ratio:0.03:last last] + //use logarithmic discretization to have more mesh points near low modules + w=real(logspace(log10(-last),log10(170*ratio),150)) + w=-w($:-1:1) + n=prod(size(w)); module=real(20*log((sin(w)*cos(teta)/sin(teta)-cos(w)))/l10) w=w/ratio @@ -174,17 +181,19 @@ function nicholschart(modules,args,colors) swap_handles(ax.children(k),ax.children(k+1)) end - drawnow() ; + fig.immediate_drawing=immediate_drawing; endfunction + function str=formatNicholsGainTip(curve,pt,index) //This function is called by the datatip mechanism to format the tip //string for the Nichols chart iso gain curves. ud=datatipGetStruct(curve); str=msprintf("%.2g"+_("dB"),ud.gain); endfunction + function str=formatNicholsPhaseTip(curve,pt,index) //This function is called by the datatip mechanism to format the tip //string for the Nichols chart iso phase curves. ud=datatipGetStruct(curve); - str=msprintf("%.2g"+_("°"),ud.phase) + str=msprintf("%.2g°",ud.phase) endfunction