How to move elements of a vector

3 次查看(过去 30 天)
cami
cami 2018-11-25
评论: cami 2018-11-26
I'd want the code that given the vector A
A=[ 1 2 4 3 0 1 5 3 7 9]
returns
A=[ 1 2 3 4 0 1 3 5 7 9]
thanks
  2 个评论
Image Analyst
Image Analyst 2018-11-25
There are many possible ways, like using deal(). What is your rule for the new order?
cami
cami 2018-11-26
i want to rebuild the original matrix...
in my case the best way would be using fliplr

请先登录,再进行评论。

回答(1 个)

Matt J
Matt J 2018-11-25
编辑:Matt J 2018-11-25
A([ 3:4:end, 4:4:end]) = A([ 4:4:end, 3:4:end])

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by