reshape                package:matlab                R Documentation

_M_A_T_L_A_B _r_e_s_h_a_p_e _f_u_n_c_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Reshape matrix or array.

_U_s_a_g_e:

     reshape(A, ...)

_A_r_g_u_m_e_n_t_s:

       A: matrix or array containing the original data

     ...: numeric dimensions for the result

_D_e_t_a_i_l_s:

     In the first example below, an 'm'-by-'n' matrix is created whose
     elements are taken column-wise from 'A'. An error occurs if 'A'
     does not have m*n elements.

     In the second example below, an 'n'-dimensional array with the
     same elements as 'A' but reshaped to have the size
     'm'-by-'n'-by-'p'. The product of the specified dimensions must be
     the same as 'prod(size(A))'.

     In the third example below, an 'n'-dimensional array with the same
     elements as 'A' but reshaped to 'siz', a vector representing the
     dimensions of the reshaped array. The quantity 'prod(siz)' must be
     the same as 'prod(size(A))'.

_V_a_l_u_e:

     Returns matrix (or array) of requested dimensions containing the
     elements of 'A'.

_A_u_t_h_o_r(_s):

     P. Roebuck, roebuck@mdanderson.org

_S_e_e _A_l_s_o:

_E_x_a_m_p_l_e_s:

     Xmat.2d <- matrix(1:12, nrow = 4, ncol = 3)
     reshape(Xmat.2d, 6, 2)                   # example 1
     reshape(Xmat.2d, c(6, 2))                    # same thing
     Xarr.3d <- reshape(Xmat.2d, c(6, 2, 1))  # example 2
     reshape(Xmat.2d, size(Xarr.3d))          # example 3

