the standard deviation of ranging measurement error to the standard deviation of computed position error

2 views (last 30 days)
clear all
close all
x1 = -30e3; % coordinates of ref station 1
y1 = 0;
x2 = 20e3; % coordinates of ref station 2
y2 = 0;
xu_true = 10e3; % true x coordinate of user
yu_true = 20e3; % true y coordinate of user [FOR CASE 2 THIS IS 5e3]
R1true = sqrt( (xu_true-x1)^2 + (yu_true-y1)^2);
R2true = sqrt( (xu_true-x2)^2 + (yu_true-y2)^2);
rng_std = 10; % standard deviation of the ranging measurement error
for i = 1:5000,
R1meas = R1true + rng_std*randn;
R2meas = R2true + rng_std*randn;
xu = 5e3; % initializing the initial guess of the user position
yu = 5e3;
delta_pos = [999999; 999999];
while norm(delta_pos) > 1e-3,
R1 = sqrt((xu-x1)^2+(xu-y1)^2) % top equation on slide 4 but use xu for x and yu for y;
% This is the computed distance from ref station 1 to the
% guessed user position
H(1,1) = (xu-x1)/R1 % (1,1) element of bottom right 2x2 matix on slide 4
H(1,2) = (yu-y1)/R1 % (1,2) element of bottom right 2x2 matix on slide 4
R2 = sqrt((xu-x2)^2+(yu-y2)^2) % similar as above
H(2,1) = (xu-x2)/R2
H(2,2) = (yu-y2)/R2
deltaR = [1600;100]; % this is a 2x1 vector consisting of the range
% measurements minus the ranges calculated from the
% ref stations to the guessed user position
delta_pos =[44.7;-22.5] % final equation on slide 4 (or use ordinary least
% squares; i.e., eqns 9 or 10 on page 2 of the
% Mod04 linearization handout)
xu = xu + delta_pos(1);
yu = yu + delta_pos(2);
end
xu_err(i) = xu - xu_true;
yu_err(i) = yu - yu_true;
horz_err(i) = sqrt(xu_err(i)^2 + yu_err(i)^2);
end
plot(xu_err,yu_err,'.')
ylabel('y error [m]')
xlabel('x error [m]')
axis equal
Htru(1,1) = (xu_true-x1)/R1true;
Htru(1,2) = (yu_true-y1)/R1true;
Htru(2,1) = (xu_true-x2)/R2true;
Htru(2,2) = (yu_true-y2)/R2true;
G = [1 0;1 0];
XDOP = 0.9
YDOP = 2.55
HDOP = 1.41
theoretical_x_err_std = 1414
sim_x_err_std = std(xu_err)
theoretical_y_err_std = 10;
sim_y_err_std = std(yu_err)
theoretical_h_err_std = 10^4;
sim_horz_err_std = sqrt( sim_x_err_std^2 + sim_y_err_std^2 );
Why i can not get my plot? When i run the program still running with out stop in the command windows, when i select pause stop and i have values in the workspace and in the command windows but the quit debugging show red(first time) im a new guys learning matlab but now im confuse. Any one can help me what is wrong with the program and guide me to the correct path?? thanks in advance.

Accepted Answer

Abhishek Kumar
Abhishek Kumar on 28 Sep 2020
Edited: Abhishek Kumar on 28 Sep 2020
Having studied your code, there seems to be a logical error in "while loop":
>>while norm(delta_pos) > 1e-3
compares "norm(delta_pos)" but delta_pos is hard coded with a fixed value within loop:
>>deltaR = [1600;100]; % this is a 2x1 vector consisting of the range
>> % measurements minus the ranges calculated from the
>> % ref stations to the guessed user position
>>delta_pos =[44.7;-22.5] % final equation on slide 4 (or use ordinary least
This results in an infinite loop. You need to correct this error, other than that, you can use "figure" container to hold the "plot":
>>figure;
>>plot(xu_err,yu_err,'.');
>>ylabel('y error [m]');
>>xlabel('x error [m]');
You can learn about "figure" by using following link:

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!