Javascript 2d Array Functions Matlab Help