Is my plot is right ?

I want to plot fft of my voice signal is my code is right ?
clc;
clear all;
close all;
Fs=96000; % Sampling frequency
T=1/Fs; % Sampling period
L = 450000; % Length of signal
t = (0:L-0)*T; % Time vector
recorder = audiorecorder(Fs, 24, 1);
pause(2)
disp('Start speaking.')
recorder.record(t(end));
while recorder.isrecording()
pause(0.1);
subplot(2,1,1);
plot(recorder.getaudiodata());
title('live recording of sound(t)')
Y=fft(recorder.getaudiodata());
drawnow();
end
disp('End of Recording.');
subplot(2,1,2);
P2 = abs(Y/L);
the_length_0f_P2=length(P2)
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
plot(f,P1) ;
title('Single-Sided Amplitude Spectrum of X(t)');
xlabel('f (Hz)');
ylabel('|P1(f)|')

4 comentarios

OCDER
OCDER el 31 de Jul. de 2018
What's wrong? What's right?
tomer polsky
tomer polsky el 1 de Ag. de 2018
the fft plot , I dont know if it is right
jonas
jonas el 1 de Ag. de 2018
What is right is ambiguous. Unless you've got an error message, then matlab says it's wrong.
Adam
Adam el 1 de Ag. de 2018
Why are you doing this:
Y=fft(recorder.getaudiodata());
in a while loop? You are just throwing away all the results apart from the last one.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Fourier Analysis and Filtering en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 31 de Jul. de 2018

Comentada:

el 1 de Ag. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by