Finding exact rank of a matrix element

조회 수: 2 (최근 30일)
Poulomi Ganguli
Poulomi Ganguli 2019년 7월 30일
댓글: Poulomi Ganguli 2019년 7월 30일
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
Guillaume
Guillaume 2019년 7월 30일
1) Please use valid matlab syntax to create your example, so we don't spend time wondering what the matrices actually are. I suspect, but it's not obvious that:
A = [1 61180
2 61280
3 61380
4 61480
5 61580];
B = [61380
61480
61180
61280
61580];
It also makes it easy for us to copy/paste directly into matlab. Any complication you introduce make it less likely for you to get an answer.
2) What do you call the rank of an element? And which elements are you talking about?
Is your question actually: How do I look up the elements of vector B in column 2 of A to get the corresponding values in column 1 of A?
Poulomi Ganguli
Poulomi Ganguli 2019년 7월 30일
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

댓글을 달려면 로그인하십시오.

채택된 답변

Guillaume
Guillaume 2019년 7월 30일
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
Poulomi Ganguli
Poulomi Ganguli 2019년 7월 30일
Exactly, what I wanted; you saved my life.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by