Typescript Remove Last Element Of Array Matlab For Loop