MATLAB Human Voice Spectrum using Matlab

Click For Summary
SUMMARY

This discussion focuses on analyzing the human voice spectrum using Matlab, specifically comparing male and female voices. The user encountered an error related to the obsolete 'spectrum' function, which requires the use of spectrum objects instead. The solution provided involves modifying the code to retrieve frequency as a second output from the 'spectrum' function, allowing for correct plotting of the frequency domain. The corrected line of code is [Y, freq]=spectrum(y,FFTsize), which should replace the original frequency variable in the plot command.

PREREQUISITES
  • Understanding of Matlab programming and syntax
  • Familiarity with Fast Fourier Transform (FFT) concepts
  • Knowledge of audio signal processing
  • Experience with plotting in Matlab
NEXT STEPS
  • Explore Matlab's spectrum objects and their usage
  • Learn about Fast Fourier Transform (FFT) in Matlab
  • Investigate audio signal recording techniques in Matlab
  • Study advanced plotting techniques in Matlab for signal analysis
USEFUL FOR

Audio engineers, signal processing researchers, and Matlab users interested in voice analysis and spectrum visualization.

frenzal_dude
Messages
76
Reaction score
0
Hi, I'm trying to compare the spectrum of male and female voices using Matlab.
I'm using this code but I get this error:
---------------------------------
Warning: SPECTRUM is obsolete and will be removed in future versions.
Use the spectrum objects instead, type "help SPECTRUM".
> In spectrum at 106
In fft at 6
? Error using ==> plot
Vectors must be the same lengths.

Error in ==> fft at 14
plot(Freq,10*log10(Y/max(Y)));
------------------------------
I heard that even though 'spectrum' is obsolete it should still work ok.
But I'm not sure how to plot the frequency domain using plot(Freq,10*log10(Y/max(Y))); even though they are different lengths, (which I assume they should be since my lecturer gave me this code).

Here's the .m file:

1. % Record sound and do spectrum analysis
2. Fs=8000; %sample rate used is 8kHz
3. N=Fs * 10; %the total number of samples in 10 secs of data
4. FFTsize=1024;
5. y=wavrecord(N,Fs); %collect your data
6. Y=spectrum(y,FFTsize); %compute the spectrum of your data
7. Freq=[10:Fs/FFTsize:Fs/2]; %frequency scale
8. Time=[1:N]/Fs;
9. subplot(2,1,1);
10. plot(Time,y);
11. ylabel('Amplitude'); %label the y axis
12. xlabel('Time(s)') %label the x axis
13. subplot(2,1,2);
14. plot(Freq,10*log10(Y/max(Y)));
15. ylabel('Spectrum(db)');
16. xlabel('Frequency(Hz)'); %label your x axisHope you guys can help.
frenzal
 
Physics news on Phys.org
In line 6, you have to get frequency as second output like this,
[Y, freq]=spectrum(y,FFTsize)
Now in line 14, if you plot this freq instead of Freq you will get the desired spectrum.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 1 ·
Replies
1
Views
891
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K