Skip to content
Snippets Groups Projects
Commit 53549b70 authored by Lisa Schätzle's avatar Lisa Schätzle
Browse files

Update addNoise.m

parent d1164a56
No related branches found
No related tags found
No related merge requests found
function F = addnoise(F, noiselevel)
%% ADDNOISE: Adds uniformly distributed complex pseudorandom numbers to the
% farfield operator such that the relative Frobernius error of the perturbed data
% is given by noiselevel
% INPUT: F - far field operator (ntheta x nd matrix)
% noiselevel - relative noise level (between 0 and 1)
% OUTPUT: F - perturbed far field operator
if noiselevel > 0
errMat = rand(size(F))-.5+1i*(rand(size(F))-.5); % matrix of u.i.d. numbers between 0 and 1
errMat = errMat ./ norm(errMat);
F = F + errMat * noiselevel * norm(F);
clear errMat
end
\ No newline at end of file
function Fn = addnoise(F, noiselevel)
% Adds p%=noiselevel complex valued uniformly distributed additive error to a matrix.
%
% INPUT: F Unperturbed far field matrix, nxhat*nd-array.
% noiselevel Relative noise level, between 0 and 1.
% OUTPUT: Fn Perturbed far field matrix, nxhat*nd-array.
%
% *************************************************************************************
if noiselevel > 0
errMat = rand(size(F))-.5+1i*(rand(size(F))-.5);
errMat = errMat ./ norm(errMat);
Fn = F + errMat * noiselevel * norm(F);
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment