MATLAB: How to reshape a matrix in cases where the reshape function might not work properly

arrayMATLABreshapetransposevectorvectors

I have a 4×5 array of zeroes which I would like to populate using elements from this 1 x 20 vector.:
X = [19 14 18 4 17 21 4 0 13 3 19 14 15 17 14 19 4 2 19 88]
The first 5 elements of X must go in the first row of the array A, and the next 5 elements of X must go into the 2nd row, and so on…
I've tried setting up 2 for loops, but I'm stuck with the index:
for i = 1:4
for a = 1:5
A(i,a) = X(%??)
end
end
I'm not sure how to index X such that, for example, A(2,1) = X(1,6)
As another attempt to fix this, I was able to reshape X into a 5 x 4 array which satisfied my conditions (the first 4 elements of X are in row 1, the next 4 are in row 2, etc.) however, it is a 5×4 array and not a 4×5 array:
Y = 19 14 18 4
17 21 4 0
13 3 19 14
15 17 14 19
4 2 19 88
Attempting to use reshape to turn it into a 4×5 array does not work since it doesn't give me the correct output, and neither does transposing the array. I'd appreciate some help with this. Thanks!

Best Answer

A = reshape(X, 5, 4).' ;