MATLAB uses column major order. You can read more about that here. An array is stored in memory as a continuous list of numbers. Systems that use column major order stores the columns of data, head to tail. The manipulation you want to do assumes the data is stored in row major order instead.
The simplest way to transform data between the two systems is to transpose it. That means transpose A, reshape it, and transpose it back. That can be done easily enough with the following code.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.