selecting specific rows from a matrix corresponding to the columns of other matrix

1 回表示 (過去 30 日間)
SBS
SBS 2020 年 2 月 19 日
コメント済み: SBS 2020 年 2 月 19 日
Hello,
I have matrix A(40x2) and a big Matrix B (25000x9). suppose my matrix A is like
250 300
356 407
433 489 and so on..I need to select rows corresponding to these columns (i.e. 250 to 300, again 356 to 407) from matrix B and put it to matrix C.
Can anyone please suggest me how to do that? Thanks in advance.

採用された回答

KSSV
KSSV 2020 年 2 月 19 日
Let A abd B be your matrices of size 40*2 and 25000*9.
[m,n] = size(A) ;
C = cell(m,1) ;
for i = 1:m
C{i} = B(A(i,1):A(i,2),:) ;
end
C = cell2mat(C) ;
  1 件のコメント
SBS
SBS 2020 年 2 月 19 日
Thank you so much. It helped a lot and worked perfectly.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by