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

1 次查看(过去 30 天)
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?

采纳的回答

Cris LaPierre
Cris LaPierre 2022-6-21
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.

更多回答(0 个)

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by