i was trying this code but getting error for Y=fft(x.*h​amming(len​gth(x))); as .* operator matrix dimensions must agree.pls help me to resolve.

2 visualizzazioni (ultimi 30 giorni)
% estimation of fundamental frequency in frequency domain
[x,fs]=wavread('1.wav',[24120 25930]);
ms1=fs/1000; % maximum speech Fx at 1000Hz
ms20=fs/50; % minimum speech Fx at 50Hz
% plot waveform
t=(0:length(x)-1)/fs; % times of sampling instants
subplot(3,1,1);
plot(t,x);
legend('Waveform');
xlabel('Time (s)');
ylabel('Amplitude');
% do fourier transform of windowed signal
Y=fft(x.*hamming(length(x)));
% plot spectrum of bottom 5000Hz
hz5000=5000*length(Y)/fs;
f=(0:hz5000)*fs/length(Y);
subplot(3,1,2);
plot(f,20*log10(abs(Y(1:length(f)))+eps));
legend('Spectrum');
xlabel('Frequency (Hz)');
ylabel('Magnitude (dB)');
% cepstrum is DFT of log spectrum
C=fft(log(abs(Y)+eps));
% plot between 1ms (=1000Hz) and 20ms (=50Hz)
q=(ms1:ms20)/fs;
subplot(3,1,3);
plot(q,abs(C(ms1:ms20)));
legend('Cepstrum');
xlabel('Quefrency (s)');
ylabel('Amplitude');

Risposta accettata

Honglei Chen
Honglei Chen il 12 Nov 2014
My guess is your x is a row vector while hamming(length(x)) gives a column vector. You can add
x = x(:);
after second line to resolve this issue.

Più risposte (0)

Categorie

Scopri di più su Signal Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by