%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55
% file: addNoise.m
% author: Jakob Möderl
% date: 03.11.2023
% description:
%   function NOISYSAMPLE
%   noisySample = addNoise(sample, SNR_dB, Es_breathing_median) adds noise
%   to the provided sample such that the desired SNR in dB is achieved

function noisySample = addNoise(sample, SNR_dB, Es_breathing_median)
N = size(sample, 1);
M = size(sample, 2);

noise_var = 1/(2*M*N) * Es_breathing_median/(10^(SNR_dB/10));
noise = sqrt(noise_var)*(randn(size(sample)) + 1j*randn(size(sample)));

noisySample = sample + noise;

end

