How to add noise to signal

2 次查看(过去 30 天)
LB
LB 2019-3-15
评论: LB 2019-3-15
Hello
I am a beginner in using MATLAB. And I am working on a project for indoor localization. I have 4 accesses points. the codes that I wrote will first generate synthetic data according to some parameters entered by the user of the program. then some calculation is done to find the location of this points and thier distances from tha access points. then in one part of this project I should add noise to the received signals. I used the following code to add the noise
PrAP1 = ((-10*app.n*log10(app.AP1_dist))+app.AP1_A); %to calculate the power of signal
PrAP2 = ((-10*app.n*log10(app.AP2_dist))+app.AP2_A);
PrAP3 = ((-10*app.n*log10(app.AP3_dist))+app.AP3_A);
PrAP4 = ((-10*app.n*log10(app.AP4_dist))+app.AP4_A);
Si= size(PrAP1,1); %to know the size of the power vector
rand1= rand(Si,1); %generate random numbers to use as probability in norminv function
rand2= rand(Si,1);
rand3= rand(Si,1);
rand4= rand(Si,1);
PrAP1= PrAP1 + (norminv(rand1,0,app.noise)); %add the noise to the calculated power
PrAP2= PrAP2 + (norminv(rand2,0,app.noise));
PrAP3= PrAP3 + (norminv(rand3,0,app.noise));
PrAP4= PrAP4 + (norminv(rand4,0,app.noise));
After calculating the power matrix there is other codes to generate estimated points according to these values and at the end it calculates the average error between the synthetic data and the estimated data.
the code worked and give me good results. For example when I put the noise as 0.0001 it gives me average error of 0
but my problem is when I put the noise = 0 it returns NAN. what causes this problem? And how can I solve it?
I hope that my question is clear
  2 个评论
KALYAN ACHARJYA
KALYAN ACHARJYA 2019-3-15
Can you illustrate the problem in simpler (more general) way?
norminv(0.0001)
ans =
-3.7190
>> norminv(0)
ans =
-Inf
LB
LB 2019-3-15
norminv function is as follows : norminve(p,mu,sigma)
it will always give inf if sigma =0 ???

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by