Thursday, October 31, 2013

Matlab Reshape Matrix

Recently I faced a problem with reshaping a matrix. Here is how I solved it.

Input: x = n*1 matrix
Output: y = a*b matrix where a*b = n

Example:

       [1
        2
x =  3
       4
       5
       6 ]

      [ 1  2
y =  3  4
       5  6]

Code:

y = reshape(x, 2, 3)
y = transpose(y)
 

0 comments:

Post a Comment