フィルターのクリア

Move multiple rows with exceptions

1 回表示 (過去 30 日間)
Rishi Balasubramanian
Rishi Balasubramanian 2020 年 12 月 23 日
回答済み: Cris LaPierre 2020 年 12 月 23 日
Hey
Consider I have a mxn matrix of binary data. I want to move the rows with 1s in it corresponding to a particular column except one row. How to achieve that?
%For example consider my matrix
% a b c d e f g h i j k l
H = [0 0 1 1 0 1 0 1 0 1 1 0; %1
0 0 0 1 0 1 1 0 1 0 1 0; %2
0 1 1 0 0 1 1 1 0 0 0 1; %3
0 1 1 0 1 0 1 0 1 0 0 1; %4
0 0 0 1 1 0 0 1 1 0 0 0; %5
0 1 0 0 1 0 0 0 0 0 1 0]; %6
% I want to move row 2&3 except row 4 corresponding to column g such that my resultant matrix must be
% a b c d e f g h i j k l
H = [0 0 1 1 0 1 0 1 0 1 1 0; %1
0 1 1 0 1 0 1 0 1 0 0 1; %4
0 0 0 1 1 0 0 1 1 0 0 0; %5
0 1 0 0 1 0 0 0 0 0 1 0; %6
0 0 0 1 0 1 1 0 1 0 1 0; %2
0 1 1 0 0 1 1 1 0 0 0 1]; %3
%Any help is appreciated. Thanks in advance

回答 (1 件)

Cris LaPierre
Cris LaPierre 2020 年 12 月 23 日
H = H([1 4:6 2 3],:)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by