add_noise.m

来自「toa代码仿真」· M 代码 · 共 21 行

M
21
字号
function out=add_noise(v,rate,down,up)
% add impulsive NLOS error to normal error
% v: normal location error
% rate: the ratio of impulsive NLOS error to the lenght of normal error
% up: up bound of impulsive NLOS error
% down: down bound of impulsive NLOS error


        N=round(length(v)*rate);
        
        nlos=down+(up-down)*rand(1,N);
        
        K=length(v);
        
        out(1:K)=0;
        
        for n=1:N
            index=randint(1,1,K-1)+1;
            out(index)=v(index)+nlos(n);
        end
        out=out+v;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?