フィルターのクリア

How to flip every 5th row and column in matrix

1 回表示 (過去 30 日間)
Matija Kosak
Matija Kosak 2018 年 7 月 4 日
編集済み: Stephen23 2018 年 7 月 4 日
For exaple I have
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 10
11 11 11
12 12 12
and I need to get
1 1 1
2 2 2
3 3 3
6 6 6
5 5 5
4 4 4
7 7 7
8 8 8
9 9 9
12 12 12
11 11 11
10 10 10
If I have matrix 12x3 and I divide it in 4 smaller matrix, I have to flip rows in every other matrix. I hope you got what I need.
  1 件のコメント
Dennis
Dennis 2018 年 7 月 4 日
A=[1 1 1; 2 2 2; 3 3 3; 4 4 4; 5 5 5; 6 6 6; 7 7 7; 8 8 8; 9 9 9; 10 10 10; 11 11 11; 12 12 12];
for k=0:1
A(k*6+4:k*6+6,1:3)=A(k*6+6:-1:k*6+4,1:3)
end

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

採用された回答

Stephen23
Stephen23 2018 年 7 月 4 日
編集済み: Stephen23 2018 年 7 月 4 日
>> M = repmat((1:12).',1,3)
M =
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5
6 6 6
7 7 7
8 8 8
9 9 9
10 10 10
11 11 11
12 12 12
>> M([4:6:end,6:6:end],:) = M([6:6:end,4:6:end],:)
M =
1 1 1
2 2 2
3 3 3
6 6 6
5 5 5
4 4 4
7 7 7
8 8 8
9 9 9
12 12 12
11 11 11
10 10 10

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by