The samples from an array can be converted and saved as an audio file using the built-in function: audiowrite.
The basic syntax for using the function is the following:
filename – a string containing the name of the file. Example: ‘testSignal.wav’
y – an array containing the samples of the audio signal.
Fs – a scalar of the sound file’s sampling rate.
Further documentation for the function is available here.