Matlab matrix main array solution