chan算法
① 我想用matlab进行CHAN算法仿真,求程序
function X = Chan_3BS(MSP,R,Noise)
% Chan 算法,利用3BS对MS进行定位;
% CHAN_3BS:
% 参数说明:
% Noise: 测距误差方差.
% R: 小区半径.
% Also see: Chan_3BS.
% 参数检测:
if nargout ~=1,
error('Too many output arguments!');
end
if nargin ~= 3,
error('input arguments error!');
end
% 算法开始
MS = R*MSP;
BS = R*NetworkTop(3);
% A矩阵:
X21 = BS(1,2) - BS(1,1);
X31 = BS(1,3) - BS(1,1);
Y21 = BS(2,2) - BS(2,1);
Y31 = BS(2,3) - BS(2,1);
A = inv([X21,Y21;X31,Y31]);
% B矩阵:
R1 = sqrt((BS(1,1) - MS(1))^2 + (BS(2,1) - MS(2))^2);
R2 = sqrt((BS(1,2) - MS(1))^2 + (BS(2,2) - MS(2))^2);
R3 = sqrt((BS(1,3) - MS(1))^2 + (BS(2,3) - MS(2))^2);
R21 = R2 - R1 + MeaNoise(Noise); % 需要加噪声
R31 = R3 - R1 + MeaNoise(Noise);
B = [R21;R31];
% C矩阵:
K1 = BS(1,1)^2 + BS(2,1)^2;
K2 = BS(1,2)^2 + BS(2,2)^2;
K3 = BS(1,3)^2 + BS(2,3)^2;
C = 0.5*[R21^2 - K2 + K1; R31^2 - K3 + K1];
% 一元二次方程的系数:
a = B'*A'*A*B - 1;
b = B'*A'*A*C + C'*A'*A*B;
c = C'*A'*A*C;
% 方程的两个根:
root1 = abs((-b + sqrt(b^2 - 4*a*c))/(2*a));
root2 = abs((-b - sqrt(b^2 - 4*a*c))/(2*a));
% 检验方程的根:
if root1 < R,
EMS = -A*(B*root1 + C);
else
EMS = -A*(B*root2 + C);
end
% 输出结果:
if nargout == 1,
X = EMS;
else
disp(EMS);
end
② chan绠楁硶鏄浠涔堟剰镐濓纻
浠涔堟槸chan绠楁硶锛熺亩鍗曟潵璇达纴瀹冩槸涓绉嶈В鍐冲嚫鍖呴梾棰樼殑绠楁硶銆傚嚫鍖呴梾棰樻槸璁$畻涓缁勭偣镄勬渶灏忓嚫鍖呯殑闂棰桡纴钥宑han绠楁硶鍒欐槸鍦ㄨ$畻鍑稿寘镞讹纴浼桦寲浼犵粺镄凣raham绠楁硶鍜孞arvis绠楁硶镄勬晥鐜囧拰鎴愭湰銆傞氲繃灏嗙偣镄勯泦钖埚垎鎴愬皬镄勫瓙闆嗭纴骞跺埄鐢ㄩ儴鍒嗙粨鏋沧潵璁$畻鍑稿寘锛宑han绠楁硶鑳藉湪镟寸煭镄勬椂闂村唴瀹屾垚杩欓”浠诲姟銆
chan绠楁硶镄勫师鐞嗘槸浠涔堬纻
chan绠楁硶鏄濡备綍璇嗗埆鍑稿寘镄勶纻瀹冨熀浜庣敱涓や釜瀛愰梾棰樼粍鎴愮殑濂楄矾锛氭垒鍒扮偣闆嗙殑链灏忓嚫鍖咃纴骞跺皢镣瑰垝鍒嗕负灏忛儴鍒嗐傞氲繃镓惧埌姣忎釜瀛愰泦镄勭Щ浜ょ偣锛宑han绠楁硶鑳藉熻$畻鍑烘暣涓镣归泦镄勫嚫鍖呫傞殢镌闂棰樼殑鍙桦缑镟村姞澶嶆潅锛宑han绠楁硶镄勮繍琛岄熷害浠岖劧闱炲父楂桡纴杩欐槸鐢卞叾鍒涙柊镐濈淮銆佸叿链夎嚜阃傚簲瑙e喅鏂规埚拰鍒呜屾不涔嬬殑鏂规硶镓鍐冲畾镄勚
chan绠楁硶鍦ㄨ稿氶嗗烟閮芥湁骞挎硾镄勫簲鐢ㄣ备緥濡傦纴瀹冨彲鐢ㄤ簬CAD杞浠朵腑镄勫嚑浣曟暟鎹搴掳纴涔熷彲鐢ㄤ簬鍏ㄦ伅鎴愬儚鍜岀嚎镐ц勫垝镄勬ц兘浼桦寲銆俢han绠楁硶杩樻槸鍏朵粬绠楁硶镄勫熀纭锛屽备骇鐢2D鍗婇忔槑瀵硅薄锛埚傞紶镙囨寚阍堬级锛屼互鍙婃父鎴忓紑鍙戜腑镄勭版挒妫娴嬨傛棤璁虹敤浜庡摢绉嶅簲鐢锛宑han绠楁硶閮芥槸鍏堣繘涓旈珮鏁堢殑瑙e喅鏂规堬纴鍙浠ヤ负璁$畻链虹戝﹀拰绂绘暎鏁板﹂嗗烟镄勫墠娌跨爷绌跺仛鍑洪吨瑕佽础鐚銆