
Thien D. answered 07/12/19
MS in Biomedical Engineering with 4 Years of MATLAB Experience
MATLAB likes you to set initialize all the variables in the beginning, so make a new matrix called new_audio and save that to be a zero matrix with the same size as original audio recording. A matrix is specifically a 2-D array in MATLAB speak.
You could either:
(1) use a for loop to step through each of the rows of both the new_audio and voice matrixes, add the noise to each row of the new_audio matrix, and save the result to the new_audio matrix.
(2) use the 'repmat' function to duplicate the noise such that there is a new matrix with m rows, where m is the number of rows in the voice matrix. Add this noise matrix to the voice matrix to get your new_audio matrix. This is probably the easiest for MATLAB to do, as more for loops takes more computation time.