I need concerning this small problem:
Let's say that I have a matrix:
A =
11 22 33
44 55 66
11 11 11
22 22 22
...
and so on, all rows are unique, size: 3xn
Now I want to check this matrix for specific row entry... let's say I want to know the location of the [11 11 11] "vector".
Is there a simple command for this or do I need to code the check myself?
Thanks!
>Is there a simple command for this or do I need to code the check myself?
ismember(A, [11 11 11] ,'rows')
(which I agree isn't easy to guess, though your question is a common one)
to allow some tolerance (e.g. floating point error):
% engine;
locrow = @(A,x,tol)find(sum(abs(bsxfun(@minus,A,x)),2) <= tol)
% usage;
tol = 0.01
locrow(A,[11.0001, 11.0001, 10.9999], tol)
suppose there was a similar problem to above where the rows were not unique. Is there a way to count the occurances of a row from matrix X in matrix Y without a loop?
Thanks,
Eamonn
Check out the second output of ISMEMBER, then use FIND+SUM, or UNIQUE+HISTC or ACCUMARRAY or SPARSE, depending what exactly you want to do. If you want to set a floating point tolerance, use ISMEMBERF on FEX instead.
Bruno