필터 지우기
필터 지우기

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 CenterFile Exchange에서 Parametric Spectral Estimation에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by