Dear everybody,
I have this code. But it appears to not work correctly for small cell sizes.
The first step in my code is to define the gridded area of interest defined by boxx and boxy which I create bellow. I am then given two vectors
lon_gsod_tm = [-123 -70]
lat_gsod_tm = [35 34]
I have to find to which box on my created grid these two (or more) points belong two. I put these indecies into box_index cell array. Sometimes (depending on the cell size) the box_index{i} will contain several points. Other times only one point or no points at all. Right now the program seems to have problem when the point fall on the edge of the box....I know I am not suppose to complain but...grrrrrrr....I guess if somebody has a solution I would be very thankful!!!!
% the area of interest
lon1 = -65;
lon2 = -125;
lat1 = 22;
lat2 = 49;
% box size
box_x = 2.0;
box_y = 2.0;
% creating the grid
kx = 1;
ky = 1;
boxx = [];
boxy = [];
for ix=lon2:box_x:lon1
for iy=lat1:box_y:lat2
boxx(kx,ky) = ix;
boxy(kx,ky) = iy;
ky = ky + 1;
end
ky = 1;
kx = kx + 1;
end
lon_gsod_tm = [-123 -70]
lat_gsod_tm = [35 34]
% box_index contains the indecies of data falling into the same "box"
box_index = {};
ka = 1;
% flag is for initialization
flag = 1;
si = size(boxx);
for i = 1:si(1)-1
for j = 1:si(2)-1
for data = 1:length(lon_gsod_tm)
% flag_eq is to for the special case when we are on the edge of the
% box; we will set it to one when it is the case
flag_eq = 0;
if lon_gsod_tm(data) <= boxx(i+1,j) & lon_gsod_tm(data) >= boxx(i,j)
if lat_gsod_tm(data) <= boxy(i,j+1) & lat_gsod_tm(data) >= boxy(i,j)
if lon_gsod_tm(data) == boxx(i+1,j) | lon_gsod_tm(data) == boxx(i,j)
if lat_gsod_tm(data) == boxy(i,j+1) | lat_gsod_tm(data) == boxy(i,j)
flag_eq = 1;
str = 'hello'
if flag == 1
box_index{ka} = data;
flag = 0;
else
ind = find(box_index{ka-1}==data);
if length(ind)==0
box_index{ka-1} = cat(1, box_index{ka-1}, data);
end
end
end
end
% if we have added the index because the datum is on the boarder, do
% not do anythinn
if flag_eq == 1
continue
end
if flag == 1
box_index{ka} = data;
flag = 0;
else
box_index{ka} = cat(1, box_index{ka}, data);
end
end
end
end
ka = ka + 1;
flag = 1;
end
end
|
|
0
|
|
|
|
Reply
|
jenya
|
3/5/2010 9:02:20 PM |
|
|
0 Replies
268 Views
(page loaded in 0.046 seconds)
Similiar Articles: matlab (given three points , how to find a circular arc. ) - comp ...how to find a point on the grid - comp.soft-sys.matlab matlab (given three points , how to find a circular arc. ) - comp ... there is 3 points. p1(x1,y1) p2(x2,y2) p3(x3 ... find y of x - comp.soft-sys.matlab... but still discrete) grid of x-values, which will enable you to find y values on a finer grid. > > Wayne Hi Wayne, What I have to do is to mark a specific point ... IDL natural neighbor interpolation for 3D irregular grid onto 3D ...I have a 3D irregular spaced grid with scalar data defined at each point ( x,y,z, and f(x,y,z) ). I want to interpolate to find the value at very sp... how do you put images on a screen? - comp.lang.java.help ...(/n/-up printing is a grid layout of the same item, /n/ to a ... How do I find which exact JRE the java executable is point to ... how do you put images on a screen? - comp ... Tpaps grid density change - comp.soft-sys.matlabI have used the tpaps function on many of my data sets and it forces a 10x10 grid ... Tpaps seems to divides the delta between the two farthest points in each dimension by ... plotting two dimension grid array - comp.lang.idl-pvwave ...I have a two dimensions data set of FLTARR (num_point, nx , ny), I would like to plot this data into a 2D grid array of nx by ny. I would appreciat... griddata - NaN - comp.soft-sys.matlabRES is a (1×1×c)-size vector. > > How can I do it? Not by using interp2. Use griddata. ... observation is 3d then converted to my grid point by interp2 ... how to avoid ... Finding x & y points from graphs - comp.soft-sys.matlabfinding the point of inflexion - comp.soft-sys.matlab Answers Best Answer: The quote from level-1 book only tells how to find stationary points: they are points where, on ... Displaying Overlapping Data Points - comp.soft-sys.gis.esri ...> > I have seen some maps where this happens, they overcame this by having > a line coming form the grid reference to the displayed point for only > the clustered points. Creating a color map with opengl - comp.graphics.api.opengl ...Hi all, I got a grid of nxm values which i want to represent with a color. So the at first i would get grid where the are nxm point with differen... How to Find the Distance Between Two Points on a Grid | eHow.comThe length of a line segment on a graph is dependent on the grid coordinates of its endpoints. A grid is constructed of two axes: the y-axis, which is a vertical line ... How to Locate Points on a Grid | eHow.comScientists and engineers use coordinate grids in a range of applications, from plotting geographical locations to graphing the behavior of electrical signals ... 7/15/2012 7:30:34 AM
|