Select data values from within a range
So I have a matrix of about 42000 rows, which give latitudes and longitudes of each entry in columns 7 and 8 respectively. Right now, my script pulls latitudes and longitudes as variables, and then another couple lines select values within a range. My script is below:
lat_r = A(:,7);
long_r = A(:,8);
lat = lat_r(lat_r > x & lat_r < y);
long = long_r(long_r > a & long_r < b);
My problem is that this only lists each value from each individual column that is between the given values (x,y or a,b). What I’d like to do is be able to find which rows have a latitude within the given range and then check if the corresponding longitude is also within the given range, then enter these values into a nx2 matrix.
This is probably a quick answer, but I’m fairly new working with MATLAB so any help would be greatly appreciated.So I have a matrix of about 42000 rows, which give latitudes and longitudes of each entry in columns 7 and 8 respectively. Right now, my script pulls latitudes and longitudes as variables, and then another couple lines select values within a range. My script is below:
lat_r = A(:,7);
long_r = A(:,8);
lat = lat_r(lat_r > x & lat_r < y);
long = long_r(long_r > a & long_r < b);
My problem is that this only lists each value from each individual column that is between the given values (x,y or a,b). What I’d like to do is be able to find which rows have a latitude within the given range and then check if the corresponding longitude is also within the given range, then enter these values into a nx2 matrix.
This is probably a quick answer, but I’m fairly new working with MATLAB so any help would be greatly appreciated. So I have a matrix of about 42000 rows, which give latitudes and longitudes of each entry in columns 7 and 8 respectively. Right now, my script pulls latitudes and longitudes as variables, and then another couple lines select values within a range. My script is below:
lat_r = A(:,7);
long_r = A(:,8);
lat = lat_r(lat_r > x & lat_r < y);
long = long_r(long_r > a & long_r < b);
My problem is that this only lists each value from each individual column that is between the given values (x,y or a,b). What I’d like to do is be able to find which rows have a latitude within the given range and then check if the corresponding longitude is also within the given range, then enter these values into a nx2 matrix.
This is probably a quick answer, but I’m fairly new working with MATLAB so any help would be greatly appreciated. matrix, array, range MATLAB Answers — New Questions