MATLAB: How to change sampling frequency when I use audiowrite function

audiowriteMATLABsampling frequencysignal processing

Hi, I have an mp3 file that I upload to matlab using audioread function, which gives me an audio signal which is stored in a 25392×1 matrix with the sampling frequency of 22050 which is stored in a variable called 'Fs'. I am trying to save this audio signal in a 'mp4' format using the audiowrite function. When I try using the variable Fs or 22050 is gives the error following error:
Error using audiowrite (line 203)
Unsupported SampleRate value.
Error in audio_signal (line 90)
audiowrite('reconstructed_computer_male.mp4', a, 22050);
Intresting thing is, when I put in Fs*2 or 44100, the function works just fine. The problem with that is the mp4 file that is saved is not an accurate representation of the audio signal because it is twice as fast as it should be. I checked the type of the variable which is double in both cases but only one of the cases work. How can I save this audio signal with the right sampling frequency, which is 22050?

Best Answer

From the audowrite documentation for Fs:
‘When writing to .m4a or .mp4 files on Windows platforms, audiowrite supports only samples rates of 44100 and 48000’
Consider using the Signal Processing Toolbox resample funciton to resample it to one of those frequencies.
.