[scilab-Users] Problem with the function Graypolarplot

Antoine Monmayrant antoine.monmayrant at laas.fr
Tue Apr 24 22:42:31 CEST 2012


Le 23/04/12 15:06, solmyr a écrit :
> Hi,
>
> I need to build an angular sound cartography. For this, I have a row vector
> called "theta" for the value of the angle, a row vector called "r" for the
> value of radius. I also have a matrix of size [theta, r] in which are placed
> the values of sound level in dB(A). I found the function graypolarplot very
> good for that but I guess there's a problem of scale of colour...
> I tried the example of the documentation and it works well. I tried to use
> this example like base to build my own map but when I put my matrix in place
> of the original function, the scale of colormap is totally wrong...
> For example, my scale goes from 59 to 83 dB(A) and the colours displayed are
> from 60 to 70 dB(A)...
> I can copy and paste my code for you try it and tell me if you have the same
> problem.
> Thanks by advance !
>
>
> ///Background value of noise (dB(A))
> Lbdf=46;
>
> //Matrix values in dB(A), each line represents the radius
> z0=[80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5 80.5
> 80.5 80.5 80.5];
> z1=[75.5 74.5 73.1 72.5 73.1 79.6 73.1 74.1 74.6 75.5 75.5 76.3 77.9 79.3
> 78.3 78.7 75.5];
> z2=[72.5 70 71 68.5 68.5 68.6 70 70 70.9 72.4 71.8 71.8 73.3 73 73 73.1
> 72.5];
> z3=[70 67.6 67.3 65.4 65.7 66.1 67.9 67 68 68.5 68.9 70.2 69.8 70.5 70.1
> 69.9 70];
> z4=[67.6 66.5 66.1 64.2 64 67.5 65.3 65.1 67 66.6 66 65.8 66.5 67 67.3 67.4
> 67.6];
> z5=[66.5 64.9 63.9 63.3 61.8 61.5 62.7 63.9 63.7 64.9 64.6 67.8 64.8 65.1
> 68.1 66.7 66.5];
>
> //Values of discretization
>      theta=(0:%pi/8:2*%pi); //Basic discretization for the angle
>      thetai=(0:%pi/64:2*%pi); //Thin discretization to smooth the map for the
> angle
>      r=(0:5); //Basic discretization for the radius
>      ri=(0:0.1:5); //Thin discretization to smooth the map for the radius
>
> //Smoothing of the matrix, I will simplify this later...
>
>      d0=splin(theta,z0);
>      z0i=interp(thetai,theta,z0,d0);
>
>      d1=splin(theta,z1);
>      z1i=interp(thetai,theta,z1,d1);
>
>      d2=splin(theta,z2);
>      z2i=interp(thetai,theta,z2,d2);
>
>      d3=splin(theta,z3);
>      z3i=interp(thetai,theta,z3,d3);
>
>      d4=splin(theta,z4);
>      z4i=interp(thetai,theta,z4,d4);
>
>      d5=splin(theta,z5);
>      z5i=interp(thetai,theta,z5,d5);
>
>      Z=[z0i' z1i' z2i' z3i' z4i' z5i'];
>
>      for i=1:length(Z(:,1))
>          d(i,:)=splin(r,Z(i,:));
>          Zi(i,:)=interp(ri,r,Z(i,:),d(i,:));
>      end
>
> //Removing background noise to the smooth noise matrix
>
>      Lz=floor((20*log10(10^(Zi/20)-10^(Lbdf/20)))*10)/10;
>
> //Variables for the mapping
>
>      zmin=min(Lz);
>      zmax=max(Lz);
>      nz=floor((zmax-zmin)/0.1); //This is for the resolution
>
>      h=jetcolormap(nz); //Creation of the colormap
>
> //Display of the result
>
>      clf()
>      graypolarplot(thetai,ri,Lz)
>      xset('colormap',h)
>      colorbar(floor(zmin), floor(zmax+1))
>      title('Angular Noise Cartography','fontsize',3)/
>
> --
> View this message in context: http://mailinglists.scilab.org/Problem-with-the-function-Graypolarplot-tp3932414p3932414.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
Got it!
It's a bug in the function graypolarplot (I think!).

Just add this at the end of your script:

h=gcf();
h.children(2).children.children(35).cdata_mapping="scaled";

and you'll get fancy colors!
The problem is that the way data is mapped (ie translated into color) is 
not "scaled" but "direct" whereas it's "scaled" in the colorbar.

Antoine



More information about the users mailing list