%% SINAD for Signal with Sample Rate
% Create a signal with a fundamental frequency of 1 kHz and unit amplitude, sampled at 480 kHz. The signal additionally consists of the first harmonic with amplitude 0.02 and additive white Gaussian noise with variance 0.01^2.
% Determine the SINAD and compare the result with the theoretical SINAD.

fs = 48e4;
t = 0:1/fs:1-1/fs;
rng default

x = cos(2*pi*1000*t)+0.02*sin(2*pi*2000*t)+0.01*randn(size(t));
r = sinad(x,fs)
powfund = 1;
powharm = 0.02^2;
varnoise = 0.01^2;
thSINAD = 10*log10(powfund/(powharm+varnoise*(1/fs)))

% Copyright 2015 The MathWorks, Inc.