Reputation: 19
I have a matrix of 5 x 2611 + 1 dangling and I want to get from the same matrix 96x136
matrix
what I was thinking is to copy each row until it completes the 136 and so on. However, I don't know where to begin with or which function is the best to do the trick.
for example:
[2 3 5 6 7;
8 9.555 10.888 20.888 3.5;
.........................;
...................... 5]
so the matrix looks like 5*2611 + 1 I know that mat would not accept it in one row and one column because the above dimension is 2611*5 at the end I have one last element
change it in a row manner
to be
2 3 5 6 7 8 9.555 10.888 20.888 3.5 ........ 5
until the end of 136 column
and start a new row with the same order.
Upvotes: 0
Views: 406
Reputation: 78314
If you have a matrix of 5*2611
elements you can:
vec1 = reshape(mat1',1,5*2611)
vec1 = [vec1 dangler]
mat2 = reshape(vec1,96,136)
and, if I got the transpose right, you have the matrix you're looking for. If I didn't get the transpose right @Shai will come along and correct me.
Upvotes: 2
Reputation: 114816
You need to use transpose and reshape
:
A = [ 2 3 5 6 7 8;...
9 10 11 12 13];
B = reshape( A.', [3 4] ).';
B
will be of size [4 3] with elements ordered according to row stacking of A
.
Upvotes: 2