function y = ts2array(x,m,n)
    //This function converts a one dimensional time series to
    //an array of m X n matrix given by user along with original time series x
    // Example usage------
    //x = floor(100*rand(1,9))
    // x = 30.    87.    53.    30.    33.    23.    25.    85.    48.  
    //w=ts2array(x,4,3)
    //Length of Required Matrix is more than original series length
    // Hence, 3 zeros will be appended in original time series
    // w  =
    //    30.    87.    53.  
    //    30.    33.    23.  
    //    25.    85.    48.  
    //    0.     0.     0.
    //w=ts2array(x,4,2)
    //Length of Required Matrix is less than original series length
    // Hence, 1  end data points of series will be lost
    // w  =
    //    30.    87.  
    //    53.    30.  
    //    33.    23.  
    //    25.    85.  
    clc();
    A = x;
    N = length(A);
    N_act = m*n;
    if (N<N_act)
        mprintf('\n Length of Required Matrix is more than original series length\n ');
        t2 = N_act-N;
        mprintf('\n Hence, %d zeros will be appended in original time series\n', t2);
       temp = zeros(1,(m*n-N));
       A = [A temp];
     end
   if (N>N_act)
          mprintf('\n Length of Required Matrix is less than original series length\n ');
          t1 = N-N_act;
          mprintf('\n Hence, %d  end data points of series will be lost\n',t1);  
          N = N_act; 
    end
    
    z=[];
    for j=1:1:m
            p=[A(((j-1)*n+1):j*n)];
            z=[z ; p];
                
    end
    
    y= z;
endfunction
