MATLAB Answers

Rengin
0

A simple matrix question

Asked by Rengin
on 5 Aug 2019
Latest activity Answered by madhan ravi
on 5 Aug 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

  0 Comments

Sign in to comment.

Tags

4 Answers

Answer by Joel Handy on 5 Aug 2019
 Accepted Answer

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

  0 Comments

Sign in to comment.


Answer by Alex Mcaulley on 5 Aug 2019

sort(A,'descend')

  0 Comments

Sign in to comment.


Torsten
Answer by Torsten
on 5 Aug 2019

fliplr(A)

  0 Comments

Sign in to comment.


madhan ravi
Answer by madhan ravi
on 5 Aug 2019

B = flip(A)

  0 Comments

Sign in to comment.