MATLAB Answers

Finding exact rank of a matrix element

10 views (last 30 days)
Hello:
I have two matrices A and B. I am attaching some parts of original matrices. My question is: how to find elements of matrix B, in column 2 of A to get the corresponding values in column 1 of A?
  4 Comments
Poulomi Ganguli
Poulomi Ganguli on 30 Jul 2019
Sorry, yes, it is exactly same as in your explanation in comment (2). To look up the elements of vector B in column 2 of A to get the corresponding values in column 1 of A. But A and B are dismilar in size, dimension of B is 516x1 and A is 241x2. Thanks

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 30 Jul 2019
look up the elements of vector B in column 2 of A to get the corresponding values in column 1 of A. But A and B are dismilar in size, dimension of B is 516x1 and A is 241x2
In that case,
[found, where] = ismember(B, A(:, 2));
assert(all(found), 'Some elements of B were not found in A');
B(:, 2) = A(where, 1);
  1 Comment
Poulomi Ganguli
Poulomi Ganguli on 30 Jul 2019
Exactly, what I wanted; you saved my life.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by