Array Within Array Javascript Iterations Matlab