1
votes

I am using Matlab to process seismic data, each one of this assume that corresponds to a specific geographic point (known lat, long). One of the goals is to group points in the Earth's surface which are encompassed by bins of a specific radius (e.g r=10degrees). It doesn't matter if the bins are overlapping. I have used the histr() Matlab intrinsic function but this outputs the central coordinates in (lat,long) of the resulting bins and the number of data points included in a bin. However, I would also like to label the data points and be able to use these labelled data points in subsequent processing. What I have used:

lt1=load('midlats.dat');
lg1=load('midlons.dat');
len_lt=length(lt1);
len_lg=length(lg1);
nb=1;
[clats,clons,num,wnum] = histr(lt1,lg1,nb);

In which nb defines how many bins you need per angular degree.

Is this anywhere close to my goal or I am completely missing the picture??? Anyone having come across something similar? Any help/comments will be much appreciated.

1
You would have to do it separately for lat and lon but histc can also return a index of which bin your data falls into, so you can keep track of what value is in what bin.nkjt

1 Answers

0
votes

Here's a thought - you will need to define a vector of bin edges (either same for both or different), see the help for histc:

[nlt, i_lt] = histc(lt1,b_vec1);
[nlg, i_lg] = histc(lg1,b_vec2);

Now, cheating - use sub2ind to convert i_lt and i_lg, indexes of which latitude and longitude bins your data is in, into a single index.

sz = [length(i_lt),length(i_lg)];
ind = sub2ind(sz,i_lt,i_lg);

Any points with the same ind are in the same lat + lon bins. You can then select them by indexing with ind e.g. lg1(ind==1) and so on.