MATLAB: Extracting data from the matrix

datasetMATLABmatrix

I am working with big (huge) matrix. First two columns of this matrix are x and y coordinates and the rest 4 columns are some parameters (values) associated with this coordinates:
x y p1 p2 p3 p4
4.003E+05 7.162E+06 1.099E+02 -1.833E+00 1.930E-01 3.079E-03
4.003E+05 7.162E+06 1.100E+02 -1.855E+00 2.080E-01 1.005E-02
….
I have a list of x and y values and I want to extract values of p1-p4 from this matrix for these x&y coordinates. Each particular set of x&y can be found more than once in this matrix (but p1-p4 values will be different). I need to extract every set of values. I am wondering what function i can use to do it.
Thank you!
maria K

Best Answer

A = randi(20,20,6);
A([1 3 6],1:2) = A([2 4 9],1:2)+3*eps;
x = A([1 3 7 17],1:2);
[a b] = find(all(abs(bsxfun(@minus,A(:,1:2),permute(x,[3 2 1]))) < 100*eps,2));
out = cellfun(@(x)A(x,3:end),accumarray(b,a,[],@(x){x}),'un',0);