フィルターのクリア

How to flip only some rows inside a matrix?

8 ビュー (過去 30 日間)
Martha
Martha 2014 年 8 月 24 日
コメント済み: Martha 2018 年 2 月 28 日
Hi, I have a matrix xx which is a 6x20 matrix, and I want to flip only the even rows. Im trying this but is doesn't work:
f=size(xx);
f=f(1);
f=0:1:f;
f=f';
for s=f+2
xx(f,:)=fliplr(xx(f,:));
end
I will appreciate any advice. Martha

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 8 月 24 日
編集済み: Azzi Abdelmalek 2014 年 8 月 24 日
A(2:2:end,:)=fliplr(A(2:2:end,:))

その他の回答 (2 件)

the cyclist
the cyclist 2014 年 8 月 24 日
編集済み: the cyclist 2014 年 8 月 24 日
No need for a loop. Just do this:
xx(2:2:end,:) = fliplr(xx(2:2:end,:));

VAISHNAVI GATTU
VAISHNAVI GATTU 2018 年 2 月 28 日
hello, how to rotate certain elements in different rows in a matrix? for example a=[1 2 3 8; 4 5 6 4; 7 8 9 3] suppose i want all elements in second and third column to be rotated row wise. output should be a=[1 5 6 8; 4 8 9 4; 7 2 3 3]
  1 件のコメント
Martha
Martha 2018 年 2 月 28 日
a(:,2:3)=circshift(a(:,2:3),-1)

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

カテゴリ

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