Serial communication Matlab-Arduino

I use AccelStepper and MultiStepper libraries because i have six different stepper motors to be controlled and to be moved simultaneously: the motors move a robotic arm. The matrix has a number of rows equal to the number of position to be assumed by the arm and each column represent a single motor (six motors so six columns). I use a for cycle to send each row of the matrix to the function moveTo() provided by the library to move each motor: the function takes an array as an input which is represented by a single row of the matrix and when all the motors have reached their target, the for loop allow to go to the following line of the matrix and move the motors to the new target. here is a part of the code:

if (conta5==1788){ //once B has been completed store each row in a 1-D array and move the robot (1788 represents the numbers of the matrix 298 rows 6 columns)
long positions [6];
for (int i=0;i<298;i++){
for (int j=0;j<6;j++){
positions [j]=B [j];
}
steppers.moveTo(positions);
steppers.runSpeedToPosition();
}