In: Electrical Engineering
write the code in MATLAB with comments and show the inputs and results of the code for the question below.
Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds that was recorded using your phone), then take Fourier transform of the signal (probably FFT).
Code:
rec = audiorecorder(96000,16,1); %created object rec for audio
recording with default parameters
recordblocking(rec, 20); %recording the sound using object for 20
s
play(rec); %play recoding recorded
y = getaudiodata(rec); %get the data recorded in double
format
figure(1);
plot(y); %plot of the recorded signal
tsignal = fft(y,100); %taking fourier transform of the signal
recorded
Recorded signal plot and code
Fourier transform tsignal values of recorded signal
1.0e-03 *
0.0916 + 0.0000i
0.0608 + 0.1852i
-0.0937 + 0.1253i
0.0001 - 0.0078i
-0.0057 + 0.0455i
0.0087 + 0.0389i
0.0563 + 0.1675i
0.0452 + 0.0339i
-0.0117 - 0.0227i
0.0199 + 0.0147i
0.0799 + 0.1298i
-0.0988 + 0.0347i
-0.0240 + 0.0199i
-0.0709 - 0.0312i
-0.0839 - 0.0908i
0.0547 + 0.0329i
0.2478 + 0.0672i
-0.0155 + 0.1462i
-0.0848 + 0.1223i
0.0424 + 0.0772i
0.0494 - 0.0802i
0.1771 + 0.0563i
0.1773 + 0.0464i
0.0106 + 0.0605i
-0.0011 + 0.0755i
0.2136 + 0.0610i
-0.0869 + 0.0435i
-0.1571 + 0.0323i
-0.0263 - 0.0156i
0.0265 - 0.0806i
0.0117 + 0.0802i
0.0754 + 0.0361i
-0.0967 + 0.0969i
-0.1392 + 0.0532i
0.0788 - 0.0232i
-0.0170 - 0.1550i
0.0127 - 0.0705i
0.1152 - 0.0328i
0.1007 + 0.0300i
-0.1123 + 0.0329i
-0.0189 - 0.1298i
-0.0654 - 0.0627i
-0.0523 + 0.0149i
0.0009 + 0.0472i
-0.0360 - 0.0346i
-0.1074 + 0.0832i
-0.0877 + 0.0550i
-0.0363 + 0.1218i
-0.1353 + 0.0099i
-0.0313 - 0.0847i
-0.0305 + 0.0000i
-0.0313 + 0.0847i
-0.1353 - 0.0099i
-0.0363 - 0.1218i
-0.0877 - 0.0550i
-0.1074 - 0.0832i
-0.0360 + 0.0346i
0.0009 - 0.0472i
-0.0523 - 0.0149i
-0.0654 + 0.0627i
-0.0189 + 0.1298i
-0.1123 - 0.0329i
0.1007 - 0.0300i
0.1152 + 0.0328i
0.0127 + 0.0705i
-0.0170 + 0.1550i
0.0788 + 0.0232i
-0.1392 - 0.0532i
-0.0967 - 0.0969i
0.0754 - 0.0361i
0.0117 - 0.0802i
0.0265 + 0.0806i
-0.0263 + 0.0156i
-0.1571 - 0.0323i
-0.0869 - 0.0435i
0.2136 - 0.0610i
-0.0011 - 0.0755i
0.0106 - 0.0605i
0.1773 - 0.0464i
0.1771 - 0.0563i
0.0494 + 0.0802i
0.0424 - 0.0772i
-0.0848 - 0.1223i
-0.0155 - 0.1462i
0.2478 - 0.0672i
0.0547 - 0.0329i
-0.0839 + 0.0908i
-0.0709 + 0.0312i
-0.0240 - 0.0199i
-0.0988 - 0.0347i
0.0799 - 0.1298i
0.0199 - 0.0147i
-0.0117 + 0.0227i
0.0452 - 0.0339i
0.0563 - 0.1675i
0.0087 - 0.0389i
-0.0057 - 0.0455i
0.0001 + 0.0078i
-0.0937 - 0.1253i
0.0608 - 0.1852i
Screenshot of these values obtained
screenshots are taken randomly.