フィルターのクリア

how to interchange array elements

3 ビュー (過去 30 日間)
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2013 年 3 月 28 日
my input is x=[11 12 13 14 15]. my output should be y=[15 12 13 14 11]. how to interchange particular values without disturbing other elements.?

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2013 年 3 月 28 日
x = [11 12 13 14 15];
y = x;
y([end,1]) = y([1,end]);

Honglei Chen
Honglei Chen 2013 年 3 月 28 日
Not sure if this is what you are looking for, but here is one way to do it, as long as you know the order
y = x([5 2 3 4 1])
  2 件のコメント
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran 2013 年 3 月 28 日
no. first element and last element should be interchanged is my objective..
Cedric
Cedric 2013 年 3 月 28 日
y = [x(end), x(2:end-1), x(1)] ;

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by