Answered matrix reshape

  • Saturday, December 17, 2011 5:45 AM
     
     

    How do I reshape a matrix? that is, assume I have a vector of length 9 and I would like to convert it into a matrix of size 3*3, what is the appropriate way of doing that?

     

    Thanks

All Replies

  • Thursday, December 22, 2011 8:58 PM
     
     Answered

    Disclaimer: I've just started working with Sho, but...

     

    >>> v1=DoubleArray.From(range(1,10)).T
    >>> v1
    [ 1.0000
      2.0000
      3.0000
      4.0000
      5.0000
      6.0000
      7.0000
      8.0000
      9.0000]
    >>> X=reshape(v1,3,3,0)
    >>> X
    [ 1.0000  4.0000  7.0000
      2.0000  5.0000  8.0000
      3.0000  6.0000  9.0000]

     

    • Marked As Answer by r-g-b Monday, January 23, 2012 6:38 PM
    •