Error in snr calculation of denoised signal

2 views (last 30 days)
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?

Answers (1)

Image Analyst
Image Analyst on 24 Dec 2021
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.

Categories

Find more on Discrete Multiresolution Analysis in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!