Merging rows of a matrix into a number

2 views (last 30 days)
If you have the 3*1 matrix
C = [345
679
158]
and you want to change it to the 3*3 matrix (or vice versa)
C = [3 4 5
6 7 9
1 5 8]
so that you can for example sort it in descending order of the columns, how would you do this? Thank you.
  2 Comments

Sign in to comment.

Accepted Answer

Ive J
Ive J on 27 Oct 2021

More Answers (1)

Jan
Jan on 27 Oct 2021
Edited: Jan on 27 Oct 2021
C = [345
679
158];
D = rem(floor(C ./ [100, 10, 1]), 10)
D = 3×3
3 4 5 6 7 9 1 5 8

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!