Error in snr calculation of denoised signal

1 次查看(过去 30 天)
Hello,
I'm loading audio signal (.wav) and adding awgn noise vector with snr = 5,
after that I'm using wden for denoising and I want to compute the snr of the denoised signal.
my code is:
[male, Fs1] = audioread('male.wav');
% Transpose audio signals
male = male.';
snr = 5; % SNR value in dB for adding awgn noise
n = randn(size(male))*std(male)/db2mag(snr); % AWGN noise
male_noisy = n + male;
[denoised,C,L,THR] = wden(male_noisy,'heursure','s','mln',3,'db8');
SNR = snr(denoised, n);
The error I'm getting is:
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Why do I get that error?

回答(1 个)

Image Analyst
Image Analyst 2021-12-24
You forgot to give the line number it told you. Please put all the red text, not just a part of it. In particular, which of those lines threw the error.
Also, you didn't name your m-file, or any other m-file, snr.m did you? Because if it's this line
SNR = snr(denoised, n);
it might be thinking that snr is a function (meaning an m-file) or a matrix that you created. What does this say
which -all snr
See the FAQ for a thorough discussion.

类别

Help CenterFile Exchange 中查找有关 Discrete Multiresolution Analysis 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by