Matlab向量倒序。

29 Ansichten (letzte 30 Tage)
wvjganx
wvjganx am 20 Mai 2023
Beantwortet: kpwqmn am 20 Mai 2023
有个向量a=[1;4;2;3;5;6],想把它倒过来得到b=[6;5;3;2;4;1].什么函数可以实现呢

Akzeptierte Antwort

kpwqmn
kpwqmn am 20 Mai 2023
注意向量格式,我电脑上都没问题的。
clear,clc;
a=[1,4,2,3,5,6]
b=fliplr(a)
disp('----------------------------------------');
a=[1;4;2;3;5;6]
b=flipud(a)
a =
     1     4     2     3     5     6
b =
     6     5     3     2     4     1
----------------------------------------
a =
     1
     4
     2
     3
     5
     6
b =
     6
     5
     3
     2
     4
     1

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB 快速入门 finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!