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

3 Ansichten (letzte 30 Tage)
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?

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 21 Jun. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Measurements and Spatial Audio finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by