How to search for matching values

Hi. I have a table of latitude, longitude and shear wave anomaly (this is a text file). I would like to search this table for minimum shear wave anomaly within a given range of latitude and longitude (say 30 - 50 latitude, and 0 - 20 longitude). what would be the best way of doing this? i have tried using the intersect function but have problems and it doesn't return repeated values.
cheers alex

1 comentario

dpb
dpb el 22 de Oct. de 2013
Why not use min presuming this is an actual minimum?
To select subsets of the data it's convenient to use a helper function to make writing the conditions more concisely hiding the details --
ix=(iswithin(lat,30,50) & iswithin(long,0,20)); % indices that satisfy
[amin,idx]=min(dat(ix));
Above assumes a vector of lat and long; arrange the indices appropriately for your data structure. My utility function is...
function flg=iswithin(x,lo,hi)
% returns T for values within range of input
% SYNTAX:
% [log] = iswithin(x,lo,hi)
% returns T for x between lo and hi values, inclusive
flg= (x>=lo) & (x<=hi);
Simple and possible to write inline but it tends to make code much more legible to hide the logic operators...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 22 de Oct. de 2013

Comentada:

dpb
el 22 de Oct. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by