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

3 ビュー (過去 30 日間)
Jaya Sodhani
Jaya Sodhani 2022 年 6 月 21 日
コメント済み: Jaya Sodhani 2022 年 6 月 21 日
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 件)

カテゴリ

Help Center および File ExchangeMeasurements and Spatial Audio についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by