Matlab向量倒序。

조회 수: 28 (최근 30일)
wvjganx
wvjganx 2023년 5월 20일
답변: kpwqmn 2023년 5월 20일
有个向量a=[1;4;2;3;5;6],想把它倒过来得到b=[6;5;3;2;4;1].什么函数可以实现呢

채택된 답변

kpwqmn
kpwqmn 2023년 5월 20일
注意向量格式,我电脑上都没问题的。
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB 快速入门에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!