[Scilab-users] Plotting density values
Hello, I'm asking for an intelligent method to solve the following problem without a for loop. I have 2 vectors x an y with e.g. 3000 values. The range of x values is between 0 and 360 and the range of y values is between -15 and 15. I would like to plot the density of individual grid cells for e.g. dx=10, dy=1 and therefore I would need a matrix with 36x30 values where each value corresponds to the number of data points in the cell. Any idea who I can do that without a for loop? Thanks a lot Wolfgang ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Plotting density values
Hi, It sounds to me like you are trying to use histplot https://help.scilab.org/docs/5.4.1/en_US/histplot.html(y,x)? Regards, Paul On 02/25/2014 12:55 PM, SCHULZ Wolfgang wrote: Hello, I'm asking for an intelligent method to solve the following problem without a for loop. I have 2 vectors x an y with e.g. 3000 values. The range of x values is between 0 and 360 and the range of y values is between -15 and 15. I would like to plot the density of individual grid cells for e.g. dx=10, dy=1 and therefore I would need a matrix with 36x30 values where each value corresponds to the number of data points in the cell. Any idea who I can do that without a for loop? Thanks a lot Wolfgang ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users -- Paul BIGNIER Development engineer --- Scilab Enterprises 143bis rue Yves Le Coz - 78000 Versailles, France Phone: +33.1.80.77.04.69 http://www.scilab-enterprises.com ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] Plotting density values
The following function does the job but with one loop. It is based on the 1D classification function dsearch Serg Steer function occ=dsearch2D(xy,dx,dy,opt) //x,y coordinates of the points of the cloud //dx, discretization of the x axis //dy , discretization of the y axis //occ, table such as occ(i,j) contains the number of points in the //pixel [dx(i) dx(i+1)) x [dy(j) dy(j+1)) if argn(2)4 then opt='c';end if and(opt[c,d]) then error(msprintf(_(%: unknown char specifier (must be ''c'' or ''d'')\n),dsearch2D)) end if size(xy,2)2 then error(Wrong dimension for first argument) end [indx,occx]=dsearch(xy(:,1),dx,opt); occ=[]; dy=matrix(dy,1,-1); for k=1:length(dx)-1 i=find(indx==k); [indy,occy]=dsearch(xy(i,2),dy,opt); occ=[occ; occy]; end endfunction Le 25/02/2014 12:55, SCHULZ Wolfgang a écrit : Hello, I'm asking for an intelligent method to solve the following problem without a for loop. I have 2 vectors x an y with e.g. 3000 values. The range of x values is between 0 and 360 and the range of y values is between -15 and 15. I would like to plot the density of individual grid cells for e.g. dx=10, dy=1 and therefore I would need a matrix with 36x30 values where each value corresponds to the number of data points in the cell. Any idea who I can do that without a for loop? Thanks a lot Wolfgang ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users