Advertisement
hbinderup94

SNRScript

Feb 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.55 KB | None | 0 0
  1. function [x, calcSNR] = ourSNR(signal, Tsymbol, fs)
  2.  
  3. y = signal(1:Tsymbol*fs);           % First symbol of the signal - test sample
  4. N = length(y);                                        
  5. Y = fft(y);                        
  6. Yabs = abs(Y);
  7. YPower = Yabs.^2;
  8. YdB = 10*log10(YPower);             % Converting to dB
  9.  
  10. peak = max(YdB);                    % Find peak in dB
  11. noise = mean(YdB);                  % Finding noise in dB
  12.  
  13. x = peak - noise - 10*log10(N/2);   % Calculate SNR
  14.  
  15. calcSNR = snr(y);                   % To test SNR function
  16.  
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement