- #1
frenzal_dude
- 77
- 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
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