MATLAB Answers

How to right use awgn after audioread?

7 views (last 30 days)
Nik Rocky
Nik Rocky on 23 Jun 2020
Answered: Devineni Aslesha on 26 Jun 2020
Hello,
I've already found some topics, but I still don't understand what's wrong.
I want to overlay x from audioread with a Gaussian white noise with different amplitudes
SNR = 20; %maximum value
[x,Fs] = audioread([fpath,fname],[st_smp,en_smp]); %read wav file
for i = 1:SNR %for any value from 1 to SNR
test=x; %save original from changing
test = awgn(test,i); %overlay with gaussian noise and SNR = 1 dB???
anotherF()
%figure
hold on
win = 2^round(log2(Fs)-3);
win = win*4;
step = round(win/8);
specx = getspecx(test,Fs);
myspec(test,Fs,win,step,win);
ylim([0 1000]);
xlabel('t_{seconds}')
ylabel('Rotation 1/s')
colormap jet
save(FileSave, 'Traj');
fig_name = [name,'_SNR_',num2str(i),'_PLL.png'];
saveas(gcf, fig_name)
movefile(FileSave,FilePath);
movefile(fig_name,FilePath);
end
%close all
But I got exactly the opposite of what I expected
from left to right i value in awgn(test,i); grows
why is this happened?
Have I do some transformation before?
Description says:
out = awgn(in,snr) adds white Gaussian noise to the vector signal in. This syntax assumes that the power of in is 0 dBW.
what is my snr value?

  0 Comments

Sign in to comment.

Answers (1)

Devineni Aslesha
Devineni Aslesha on 26 Jun 2020
Hi Nik,
Here, the snr value increases by 1 dB for every for loop iteration. Since, some userdefined functions are used before saving the test data with added noise, I assume that the test data is being modified after overlaying it with the additive white gaussian noise.
I recommend you to check the reason for the test data being modified. However, plotting the test data after 'test = awgn(test,i);' line gives the correct results i.e. As snr increases, test data is with less noise power.

  0 Comments

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!