I need to save the audio output of a script in Matlab but I don't know how to do it. It is a complex sound, with several pauses of silence with different durations, so I cannot simply use audiowrite (for my understanding, I need one single matrix S to save a file using audiowrite(S,Fs)). A simple example of how the sound is generated would be the following:
for ii = 1:length(cf) - 1 sound(s(ii,:), sf); % sound presentation pause(d + 0.025); % waiting for sound end + silent period end
where d is the sound duration and 0.025 is the duration of the silence. I was thinking in creating a vector describing the silent period (similarly to the matrix s describing the sound), but as it has a different duration with respect to the sound so the number of columns (which represents the number of signal samples) would be different.
Is it possible to record the output? I would like to save exactly what I hear in the speakers after running the script. It is my first time with sounds in Matlab and I did not find anything online. Thank you for your help.