Typescript Reduce Sum Array Matlab Plot