フィルターのクリア

Obtain SNR for a flat spectrum

2 ビュー (過去 30 日間)
Tony Tse
Tony Tse 2018 年 9 月 28 日
回答済み: Tony Tse 2018 年 9 月 30 日
Hello,
I am trying to construct a power spectrum given a SNR and use Matlab's in-built function SNR (or SINAD) to verify this. It seems that Matlab has issue picking the fundamental power.
I have attached a sample code to demonstrate my problem. How can I get around this?
Thanks.
% check matlab function to obtain snr
sNRdB = 64;
sampleFreq = 16e6;
% generate frequency
fxx = 0:500:sampleFreq/2;
signalP = 1;
% calculate noise power from snr figure
noiseP = signalP/(10^(sNRdB/10));
% assume flat noise power density
noisePD = noiseP/(sampleFreq/2);
% populate spectrum
pxx = ones(1, length(fxx))*noisePD;
% assume signal is at fxx(10000);
pxx(10000) = 1;
figure(1);
sinad(pxx', fxx', 'psd') % or snr
% trick matlab?
pxx(10000-1) = pxx(10000-1) - eps;
pxx(10000+1) = pxx(10000+1) - eps;
figure(2);
sinad(pxx', fxx', 'psd')

回答 (1 件)

Tony Tse
Tony Tse 2018 年 9 月 30 日
Just to answer my own question, turned out I needed to divide the signal power by the frequency width. Silly me! Still need to perform the little "trick" to make sure Matlab selects the right signal/noise frequency.
% check matlab function to obtain snr
sNRdB = 64;
sampleFreq = 16e6;
% generate frequency
fxx = 0:500:sampleFreq/2;
signalP = 1;
% populate spectrum with noise
noiseP = signalP/(10^(sNRdB/10)); % calculate noise power from snr figure
noisePD = noiseP/(sampleFreq/2); % noise power density
pxx = ones(1, length(fxx))*noisePD;
% populate spectrum with signal
signalPD = signalP/mean(diff(fxx));
sigFreq = round(length(fxx)/2);
pxx(sigFreq) = signalPD; % assume signal is in the middle of the fxx;
% matlab sinad
figure(1);
sinad(pxx', fxx', 'psd') % or snr
% trick matlab sinad?
pxx(2) = pxx(2) - eps;
pxx(sigFreq-1) = pxx(sigFreq-1) - eps;
pxx(sigFreq+1) = pxx(sigFreq+1) - eps;
figure(2);
sinad(pxx', fxx', 'psd')

カテゴリ

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

タグ

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by