Clear Filters
Clear Filters

Matrix Reshaping 9x9 to 3x27

1 view (last 30 days)
Hi I'm struggling with converting a computed 9 x 9 matrix into the form of a 3x27 matrix. An exmaple of the 9x9 is given below:
8 1 4 7 9 1 2 4 9
6 1 2 7 1 4 8 1 5
5 5 8 5 4 3 6 3 5
9 8 3 1 1 8 5 2 4
3 9 5 3 9 4 2 2 9
7 2 2 9 1 9 8 3 4
7 6 6 2 7 2 6 4 2
4 5 3 8 8 3 4 1 8
6 1 6 5 8 2 5 9 4
A = 9×9
9 8 9 8 4 5 8 2 6 7 5 3 9 5 4 3 2 1 5 6 7 7 1 5 6 7 3 8 6 2 6 7 4 6 1 1 8 8 4 6 1 4 9 9 1 1 7 2 3 9 2 5 7 6 5 1 2 8 5 4 1 3 7 9 1 7 7 6 1 9 8 7 8 6 1 2 4 6 1 5 9
I would like to take the first three values of each column and use that as the columns of the new 3x27 matrix. This would be repeated for all nine values in each column to create a matrix based off the one above to look like:
8 9 7 1 8 6 4 3 6
6 3 4 1 9 5 2 5 3 etc
5 7 6 5 2 1 8 2 6
Any help or guidance would be much appreciated!

Accepted Answer

Arif Hoq
Arif Hoq on 24 Oct 2022
A=[8 1 4 7 9 1 2 4 9
6 1 2 7 1 4 8 1 5
5 5 8 5 4 3 6 3 5
9 8 3 1 1 8 5 2 4
3 9 5 3 9 4 2 2 9
7 2 2 9 1 9 8 3 4
7 6 6 2 7 2 6 4 2
4 5 3 8 8 3 4 1 8
6 1 6 5 8 2 5 9 4];
output=reshape(A(:),3,[])
output = 3×27
8 9 7 1 8 6 4 3 6 7 1 2 9 1 7 1 8 2 2 5 6 4 2 4 9 4 2 6 3 4 1 9 5 2 5 3 7 3 8 1 9 8 4 4 3 8 2 4 1 2 1 5 9 8 5 7 6 5 2 1 8 2 6 5 9 5 4 1 8 3 9 2 6 8 5 3 3 9 5 4 4

More Answers (1)

RAGHUNATHRAJU DASHARATHA
RAGHUNATHRAJU DASHARATHA on 24 Oct 2022
As per my understanding you want to convert a 9x9 matric to 3x27 matix.
I will try to explain it using an example below
a=[8 1 4 7 9 1 2 4 9
6 1 2 7 1 4 8 1 5
5 5 8 5 4 3 6 3 5
9 8 3 1 1 8 5 2 4
3 9 5 3 9 4 2 2 9
7 2 2 9 1 9 8 3 4
7 6 6 2 7 2 6 4 2
4 5 3 8 8 3 4 1 8
6 1 6 5 8 2 5 9 4];
b=reshape(a,[3,27])
b = 3×27
8 9 7 1 8 6 4 3 6 7 1 2 9 1 7 1 8 2 2 5 6 4 2 4 9 4 2 6 3 4 1 9 5 2 5 3 7 3 8 1 9 8 4 4 3 8 2 4 1 2 1 5 9 8 5 7 6 5 2 1 8 2 6 5 9 5 4 1 8 3 9 2 6 8 5 3 3 9 5 4 4
For any further information you can go through the link

Community Treasure Hunt

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

Start Hunting!