A simple matrix question

1 visualizzazione (ultimi 30 giorni)
Rengin
Rengin il 5 Ago 2019
Risposto: madhan ravi il 5 Ago 2019
%Dear users,
%Imagine that I have a matrix of A=[1,2,3,4,5]
%Is there any short-cut to get the matrix of B=[5,4,3,2,1]?
%Thanks in advance

Risposta accettata

Joel Handy
Joel Handy il 5 Ago 2019
A = [1 2 3 4 5];
B = fliplr(A) % Flip matrix in left/right direction
A = [1; 2; 3; 4; 5];
B = flipud(A) % Flip matrix in up/down direction

Più risposte (3)

Alex Mcaulley
Alex Mcaulley il 5 Ago 2019
sort(A,'descend')

Torsten
Torsten il 5 Ago 2019
fliplr(A)

madhan ravi
madhan ravi il 5 Ago 2019
B = flip(A)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by