フィルターのクリア

Obtain lines of a matrix according to its position.

2 ビュー (過去 30 日間)
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 10 月 3 日
コメント済み: Ricardo Gutierrez 2019 年 10 月 3 日
Hi. Good day.
I hope you help me solve this problem.
I have a matrix A of size 4 X 18.
I have the positions of the lines(row) that interest me to know.
For example I have the positions of lines(row) 2 and 4 and now I am interested in "" taking out "" of the matrix A the values ​​of lines(row) 2 and 4 and with these values ​​forming a matrix B
A=[ 10 87 11 10 10 10 13 10 76 82 87 89 86 10 13 88 12 90
. 84 70 76 86 90 10 10 80 69 71 72 83 68 84 11 76 10 83
. 91 99 94 10 85 80 10 88 84 88 11 10 78 81 82 86 11 86
. 71 73 74 76 73 67 86 77 76 78 86 89 78 73 79 73 91 79 ];
This would be the matrix B
B=[84 70 76 86 90 10 10 80 69 71 72 83 68 84 11 76 10 83
. 71 73 74 76 73 67 86 77 76 78 86 89 78 73 79 73 91 79]
The actual matrix A I have is 720 X 18
Thank you.
Regards.
  2 件のコメント
Diana Mae Calde
Diana Mae Calde 2019 年 10 月 3 日
Matrix is equal m x n where m is number of rows and n is number of columns
A = 720 x18 and you want a specific row to be in B
B = A(2,:); for row 2
but if you need multiple of 2
size = size(A)
for n = 1:size(1)
B = A(n,:);
n = n + 2
end
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 10 月 3 日
Thank you for the solution.
Regards

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2019 年 10 月 3 日
編集済み: Stephen23 2019 年 10 月 3 日
All you need is some very basic indexing:
B = A([2,4],:)
Very basic MATLAB concepts, like how to use indexing, are explained in the introdutory tutorials:
  1 件のコメント
Ricardo Gutierrez
Ricardo Gutierrez 2019 年 10 月 3 日
Thank you for the solution and advices
Regards

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by