# Simulating Range Bearing Sensor with MATLAB with Gaussian Noise (Generating Gaussian Colored Random Vector)

I would like to simulate a sensor that provides range and direction of a beacon. This is for EKF localization, so the noise must be Gaussian (i.e. $\mathcal{N}(0, \sigma^{2})$. Also, I would like to compute the measurement noise matrix $Q_{k}$ which is $$Q_{k} = \begin{bmatrix} \sigma^{2}_{r} & 0 \\ 0 & \sigma^{2}_{\theta} \end{bmatrix}$$

This is what I've done

sigma_range = 1;
Q = [sigma_range^2,               0;
0, sigma_angle^2];


In the sensor, this is I've done

% add Gaussian noise with zero mean and some variance
Z(1) = Z(1) + sigma_range*randn(); % Z(1) the distance btw robot and beacon
Z(2) = Z(2) + sigma_angle*randn(); % Z(2) the angle btw robot and beacon


Is this correct?

vZ = vZ + [sigma_range; sigma_angle] .* randn([2, 1]);

• 1) I think I did. The standard deviation is sigma_range (i.e. $\sigma$) – CroCo Jun 16 '14 at 23:59