Error in snr calculation of denoised signal

조회 수: 1 (최근 30일)
daniel cohen
daniel cohen 2021년 12월 24일
답변: Image Analyst 2021년 12월 24일
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