How to flip an array without using the flip command ?

23 ビュー (過去 30 日間)
sandeep das
sandeep das 2022 年 5 月 3 日
回答済み: Stephen23 2022 年 5 月 3 日
  1. Given an row vector A of any size say n
  2. I want to create a vector B of Size n with the last element of A as the First elelment of B and the first element of A as the last element of B
  3. I want to create the array B without using the FLIP command but preferably by a for loop
  1 件のコメント
sandeep das
sandeep das 2022 年 5 月 3 日
F = [-0.5 4.5 -2.0 3.6 8.5 7.3 2.5 1.2 6.5 ]
Trying to create an array P = [6.5 1.2 2.5 7.3 8.5 3.6 -2.0 4.5 -0.5]

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

採用された回答

Stephen23
Stephen23 2022 年 5 月 3 日
F = [-0.5,4.5,-2.0,3.6,8.5,7.3,2.5,1.2,6.5]
F = 1×9
-0.5000 4.5000 -2.0000 3.6000 8.5000 7.3000 2.5000 1.2000 6.5000
P = F(end:-1:1)
P = 1×9
6.5000 1.2000 2.5000 7.3000 8.5000 3.6000 -2.0000 4.5000 -0.5000

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 5 月 3 日
If the vector V length is N then the first output is V(N), the second is V(N-1), the third is V(N-2)....
You should be able to generalize to what location the Kth output is from.

カテゴリ

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

タグ

製品


リリース

R2013a

Community Treasure Hunt

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

Start Hunting!

Translated by