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