Matrix indexing multiple rows

How can I select specific rows of a matrix. For example if I have a matrix with 10 rows and 3 columns. I want rows 2-4 and rows 5-8.
My matrix is actually has 1000 rows and 6 columns but if it can be done for a small matrix, then I can do it for a larger one.

回答 (2 件)

James Tursa
James Tursa 2016 年 11 月 30 日
編集済み: James Tursa 2016 年 11 月 30 日

5 投票

x = your matrix
result = x([2:4,5:8],:); % <-- pick off rows 2-4 and 5-8
Of course, the 2:4 and 5:8 could have been combined to just 2:8 for this example, but I assume you may have variables for the row numbers in your real problem.
pinank tilavat
pinank tilavat 2020 年 4 月 12 日

1 投票

x= matrix
q= [x(2:4,:) ; x(5:8,:)]

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2016 年 11 月 30 日

回答済み:

2020 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by