I had to read data from a file and store all data in a one dimensional array.
However, Some data I have to store in a matrix (2 dimensional array) How Can I do this?
For example if my data is 1x7 array [1,2,3,1,5,2,8] and the first to 6th belong to a matrix 2x3 how can I store in a new array variable?
Suppose that your 7-element array is called
array7, then the following expression should return a2x3array containing the first 6 elements ofarray7If that puts the elements into the new array in the wrong order, try
Note that I’ve used a named optional argument in the second version, there is another optional argument (
pad) which would be, by default, the 3rd argument toreshape.