Show results in matrix.

조회 수: 11 (최근 30일)
Ricardo Gutierrez
Ricardo Gutierrez 2019년 10월 10일
댓글: Ricardo Gutierrez 2019년 10월 10일
Hi.
Good day.
I would like to give me some advice on how to solve the following.
I have two matrices A and B
Matrix A has values ​​that correspond to the lines of matrix B.
The code I have is as follows:
% __________________________________________
A = [1 3 5];
B = [19 25 31 41 11 61 77 81 31 11
   81 35 71 31 31 6 11 88 61 31
   21 81 20 61 50 31 31 31 19 12
   91 31 41 46 61 81 61 41 10 91
   12 23 45 67 89 13 26 39 26 12];
for i = 1: 1: length (A)
   plm = B (A (1, i), :)
end
________________________________
The results are the following
plm =
    19 25 31 41 11 61 77 81 31 11
plm =
    21 81 20 61 50 31 31 31 19 12
plm =
    12 23 45 67 89 13 26 39 26 12
//////////////////////////////////////////////////// /////////////////////////////
How do I get the results in an matriz?
for example like that.
plm = [19 25 31 41 11 61 77 81 31 11
          21 81 20 61 50 31 31 31 19 12
          12 23 45 67 89 13 26 39 26 12]
Thanks for your help

답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 10일
B(A, :)
  댓글 수: 1
Ricardo Gutierrez
Ricardo Gutierrez 2019년 10월 10일
Excellent !!!
Works.
Elegant solution.
Thanks so much.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by