Why my fft graph gives different output on again running the code?

3 visualizaciones (últimos 30 días)
y=audioread('speech.wav');
%sound(y);
subplot(2,3,1);
plot(y);
xlabel('Samples');
ylabel('Magnitude');
title('Original speech signal');
%adding noise
x=awgn(y,5);
z=y+x;
z=z/2;
%sound(z);
subplot(2,3,2);
plot(z);
xlabel('Samples');
ylabel('Magnitude');
title('Noise added to speech signal');
% framing
f_duration = 0.025;
fs=8000;
f_size = (f_duration.*fs);
n = length(y);
n_f = floor(n/f_size); %no. of frames
temp = 0;
fr=z(1 : f_size);
window=hamming(length(fr));
window_framing=fr.*window;
%Taking FFT
fft_sig=fft(window_framing,256);
abs_val=abs(fft_sig);
N=256;
w_axis=(2*pi*[0:N-1])/N;
subplot(2,3,3);
plot(w_axis,abs_val);
When I plot the graph of FFT, I always get different on running the again and again. Please tell me what's wrong in my code?

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 21 de Jun. de 2022
I suspect the reason it changes is because you are adding randon noise to your signal with awgn. Since that changes every time the code is run, the FFT result will look slightly different every time.

Más respuestas (0)

Categorías

Más información sobre Measurements and Spatial Audio en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by