Problems with snr function

5 ビュー (過去 30 日間)
Dick Rusell
Dick Rusell 2014 年 9 月 20 日
コメント済み: Image Analyst 2014 年 9 月 20 日
I want to find the snr for signal xn and noise ns but I keep getting an error.
clear;
n = [0:1023];
omega = 0.25*pi;
xn = sin(omega*n);
count = 1024;
ns = sqrt(0.2)*randn(1,count);
r = snr(xn,ns);
plot(r);
??? Undefined function or method 'snr' for input arguments of type 'double'.

採用された回答

Image Analyst
Image Analyst 2014 年 9 月 20 日
How about:
theRatio = xn ./ ns;
theSNR = mean(theRatio);
  2 件のコメント
Dick Rusell
Dick Rusell 2014 年 9 月 20 日
編集済み: Dick Rusell 2014 年 9 月 20 日
I'm not sure which formula you used to find snr in the first place.
Image Analyst
Image Analyst 2014 年 9 月 20 日
xn is your signal. ns is your noise. The SNR is theRatio xn/ns, but this gives the SNR element by element. So you have a bunch of SNR's - one for each element. So to get it down to just one SNR I took the mean of all the individual SNRs. If you want something different, then say what you want.

サインインしてコメントする。

その他の回答 (2 件)

Guillaume
Guillaume 2014 年 9 月 20 日
Sounds like you don't have the signal processing toolbox.
ver
will tell you which toolboxes you have installed.
  2 件のコメント
Image Analyst
Image Analyst 2014 年 9 月 20 日
編集済み: Image Analyst 2014 年 9 月 20 日
Or it's an antique version. I think snr() has not always been part of the Signal Processing Toolbox, but it's simple enough to calculate manually.
Dick Rusell
Dick Rusell 2014 年 9 月 20 日
編集済み: Dick Rusell 2014 年 9 月 20 日
I'm using matlab 2011, how would I calculate it manually?

サインインしてコメントする。


Youssef  Khmou
Youssef Khmou 2014 年 9 月 20 日
編集済み: Youssef Khmou 2014 年 9 月 20 日
Generally the formula is SNR=20log10(std(signal)/std(noise)) , in your case you have :
snr=20*log10(std(xn)/std(ns)) % 3.8dB

カテゴリ

Help Center および File ExchangeSpectral Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by