📄 locaccuracy.m
字号:
% locAccuracy.m% Given arr (a set of phone positions), calculate and plot the % accuracy of locations calculated with the time-delay estimation method.%% For example, this one looks pretty:% arr = [0 0; 0 1; 1 1; 1 0]' - 0.5 + rand(2,4)/1e5; locAccuracy%% Dave Mellinger% 11/97n = size(arr,2); % number of phoneslim = defaultLimits(arr);% res = number of points that are plotted in x and y; use (prime number)+1res = 200; % most accurate%res = 102; % intermediate%res = 60; % most speedyncolor = 17; % number of contoursx = linspace(lim(1), lim(2), res);y = linspace(lim(3), lim(4), res);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Calculate location accuracy on grid defined by x and y.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if (1) % change this 1 into 0 to avoid recalculation [h1,h2] = timesToDelays(1:n); % all pairs of phones (O(n^2) of them) [j1,j2] = timesToDelays(1:length(h1));% all pairs of pairs (O(n^4) of them!) fprintf(2, '%d dots: ', length(x)) d = zeros(res,res); for i = 1:length(x) for j = 1:length(y) jac = CalcDeltaJacobian([x(i);y(j)], arr, h1, h2, h1); d(j,i) = loccond(jac, j1,j2); end fprintf(1,'.'); end disp(' ');end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Plotting%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clfhold onif (1), d1 = -d; % linear color mappingelse d1 = -log(d); % logarithmic color mappingend% Manually scale d1 to fit the number of colors.d2 = d1 - min(min(d1));d2 = d2 / max(max(d2));xcorrection = diff(x(1:2))/4; % not clear why this is needed, but it isimage(x + xcorrection, y, round(d2 * ncolor + 0.4999));cmap = hot(round(ncolor * 1.1));colormap(cmap(size(cmap,1) - ncolor + 1 : size(cmap,1), :))contour(x, y, d2, ncolor-1, 'k')set(plot(arr(1,:), arr(2,:), 'bo'), 'LineWidth', 4)hold offaxis(lim)axis equaltitle('Relative location accuracy')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -