tdoa_method.m
上传用户:doryuen
上传日期:2013-10-30
资源大小:23k
文件大小:5k
源码类别:

通讯/手机编程

开发平台:

Matlab

  1. %finding the MS's position by TDOA algorithm
  2. function [x,y] = tdoa_method(X,Y,tdoa12,tdoa13)
  3. c = 3e8;%speed of the light
  4. r21_est = tdoa12*c;
  5. r31_est = tdoa13*c;
  6. num_BS  = 3;
  7. %coordinate differences of BSs  
  8. x21 = X(2)-X(1);
  9. y21 = Y(2)-Y(1);
  10. x31 = X(3)-X(1);
  11. y31 = Y(3)-Y(1);
  12. h = [x21 y21;x31 y31];
  13. h3 = h^(-1);
  14. detH=1/(x21*y31-x31*y21);
  15. for k = 1:num_BS
  16.     K(k) = X(k)^2 + Y(k)^2;%notation used to find MS position
  17. end
  18.     
  19. %notation used to determine estimated MS location
  20. g1 = r21_est^2 - K(2) + K(1);
  21. g2 = r31_est^2 - K(3) + K(1);
  22. G_est = [g1;g2];
  23. h2_est = [r21_est;r31_est];    
  24. r11=0.5/(4.*detH^2*y31^2*r21_est^2+4.*detH^2*y21^2*r31_est^2-4.-8.*detH^2*y31*r21_est*y21*r31_est+4.*detH^2*x31^2*r21_est^2+4.*detH^2*x21^2*r31_est^2-8.*detH^2*x31*r21_est*x21*r31_est)*(-4.*detH^2*y31^2*r21_est*g1-4.*detH^2*y21^2*r31_est*g2-8.*X(1)*detH*y31*r21_est+8.*X(1)*detH*y21*r31_est+8.*Y(1)*detH*x31*r21_est-8.*Y(1)*detH*x21*r31_est-4.*detH^2*x31^2*r21_est*g1+4.*detH^2*y31*r21_est*y21*g2+4.*detH^2*y31*g1*y21*r31_est+4.*detH^2*x31*g1*x21*r31_est-4.*detH^2*x21^2*r31_est*g2+4.*detH^2*x31*r21_est*x21*g2+4.*(detH^2*y31^2*g1^2+detH^2*x31^2*g1^2+detH^2*y21^2*g2^2-1.*detH^4*y31^2*r21_est^2*x21^2*g2^2+detH^2*x21^2*g2^2-4.*detH^3*y31^2*r21_est^2*Y(1)*x21*g2+8.*detH^2*y31*r21_est*y21*r31_est*Y(1)^2+4.*detH^3*y21^2*r31_est^2*Y(1)*x31*g1-8.*X(1)*detH^2*y31*r21_est^2*Y(1)*x31-8.*X(1)*detH^2*y21*r31_est^2*Y(1)*x21+4.*X(1)^2+4.*Y(1)^2-2.*detH^2*y31*g1*y21*g2+4.*X(1)*detH*y31*g1-4.*X(1)*detH*y21*g2-4.*Y(1)*detH*x31*g1+4.*Y(1)*detH*x21*g2-2.*detH^2*x31*g1*x21*g2-4.*detH^2*y31^2*r21_est^2*Y(1)^2-4.*detH^2*y21^2*r31_est^2*Y(1)^2-4.*detH^2*x31^2*r21_est^2*X(1)^2-4.*detH^2*x21^2*r31_est^2*X(1)^2-1.*detH^4*y21^2*r31_est^2*x31^2*g1^2+2.*detH^4*y31^2*r21_est*g1*x21^2*r31_est*g2+2.*detH^4*y21^2*r31_est*g2*x31^2*r21_est*g1-4.*detH^4*y31*r21_est*y21*g2*x31*g1*x21*r31_est+2.*detH^4*y31*r21_est^2*y21*g2^2*x31*x21+2.*detH^4*y31*g1^2*y21*r31_est^2*x31*x21-1.*detH^4*x31^2*r21_est^2*y21^2*g2^2-1.*detH^4*x21^2*r31_est^2*y31^2*g1^2+4.*detH^3*y31^2*r21_est*g1*Y(1)*x21*r31_est-4.*detH^3*y21^2*r31_est*g2*Y(1)*x31*r21_est+8.*X(1)*detH^2*y31*r21_est*Y(1)*x21*r31_est+4.*X(1)*detH^3*y31*r21_est*x31*g1*x21*r31_est+4.*X(1)*detH^3*y31*r21_est*x21^2*r31_est*g2-4.*X(1)*detH^3*y31*r21_est^2*x31*x21*g2+8.*X(1)*detH^2*y21*r31_est*Y(1)*x31*r21_est-4.*X(1)*detH^3*y21*r31_est*x31^2*r21_est*g1+4.*X(1)*detH^3*y21*r31_est^2*x31*g1*x21-4.*X(1)*detH^3*y21*r31_est*x31*r21_est*x21*g2+4.*Y(1)*detH^3*x31*r21_est^2*y31*y21*g2-4.*Y(1)*detH^3*x31*r21_est*y31*g1*y21*r31_est+4.*Y(1)*detH^3*x21*r31_est*y31*r21_est*y21*g2-4.*Y(1)*detH^3*x21*r31_est^2*y31*g1*y21+4.*detH^3*x31^2*r21_est^2*X(1)*y21*g2-4.*detH^3*x21^2*r31_est^2*X(1)*y31*g1+8.*detH^2*x31*r21_est*x21*r31_est*X(1)^2)^(1/2));
  25. r12=0.5/(4.*detH^2*y31^2*r21_est^2+4.*detH^2*y21^2*r31_est^2-4.-8.*detH^2*y31*r21_est*y21*r31_est+4.*detH^2*x31^2*r21_est^2+4.*detH^2*x21^2*r31_est^2-8.*detH^2*x31*r21_est*x21*r31_est)*(-4.*detH^2*y31^2*r21_est*g1-4.*detH^2*y21^2*r31_est*g2-8.*X(1)*detH*y31*r21_est+8.*X(1)*detH*y21*r31_est+8.*Y(1)*detH*x31*r21_est-8.*Y(1)*detH*x21*r31_est-4.*detH^2*x31^2*r21_est*g1+4.*detH^2*y31*r21_est*y21*g2+4.*detH^2*y31*g1*y21*r31_est+4.*detH^2*x31*g1*x21*r31_est-4.*detH^2*x21^2*r31_est*g2+4.*detH^2*x31*r21_est*x21*g2-4.*(detH^2*y31^2*g1^2+detH^2*x31^2*g1^2+detH^2*y21^2*g2^2-1.*detH^4*y31^2*r21_est^2*x21^2*g2^2+detH^2*x21^2*g2^2-4.*detH^3*y31^2*r21_est^2*Y(1)*x21*g2+8.*detH^2*y31*r21_est*y21*r31_est*Y(1)^2+4.*detH^3*y21^2*r31_est^2*Y(1)*x31*g1-8.*X(1)*detH^2*y31*r21_est^2*Y(1)*x31-8.*X(1)*detH^2*y21*r31_est^2*Y(1)*x21+4.*X(1)^2+4.*Y(1)^2-2.*detH^2*y31*g1*y21*g2+4.*X(1)*detH*y31*g1-4.*X(1)*detH*y21*g2-4.*Y(1)*detH*x31*g1+4.*Y(1)*detH*x21*g2-2.*detH^2*x31*g1*x21*g2-4.*detH^2*y31^2*r21_est^2*Y(1)^2-4.*detH^2*y21^2*r31_est^2*Y(1)^2-4.*detH^2*x31^2*r21_est^2*X(1)^2-4.*detH^2*x21^2*r31_est^2*X(1)^2-1.*detH^4*y21^2*r31_est^2*x31^2*g1^2+2.*detH^4*y31^2*r21_est*g1*x21^2*r31_est*g2+2.*detH^4*y21^2*r31_est*g2*x31^2*r21_est*g1-4.*detH^4*y31*r21_est*y21*g2*x31*g1*x21*r31_est+2.*detH^4*y31*r21_est^2*y21*g2^2*x31*x21+2.*detH^4*y31*g1^2*y21*r31_est^2*x31*x21-1.*detH^4*x31^2*r21_est^2*y21^2*g2^2-1.*detH^4*x21^2*r31_est^2*y31^2*g1^2+4.*detH^3*y31^2*r21_est*g1*Y(1)*x21*r31_est-4.*detH^3*y21^2*r31_est*g2*Y(1)*x31*r21_est+8.*X(1)*detH^2*y31*r21_est*Y(1)*x21*r31_est+4.*X(1)*detH^3*y31*r21_est*x31*g1*x21*r31_est+4.*X(1)*detH^3*y31*r21_est*x21^2*r31_est*g2-4.*X(1)*detH^3*y31*r21_est^2*x31*x21*g2+8.*X(1)*detH^2*y21*r31_est*Y(1)*x31*r21_est-4.*X(1)*detH^3*y21*r31_est*x31^2*r21_est*g1+4.*X(1)*detH^3*y21*r31_est^2*x31*g1*x21-4.*X(1)*detH^3*y21*r31_est*x31*r21_est*x21*g2+4.*Y(1)*detH^3*x31*r21_est^2*y31*y21*g2-4.*Y(1)*detH^3*x31*r21_est*y31*g1*y21*r31_est+4.*Y(1)*detH^3*x21*r31_est*y31*r21_est*y21*g2-4.*Y(1)*detH^3*x21*r31_est^2*y31*g1*y21+4.*detH^3*x31^2*r21_est^2*X(1)*y21*g2-4.*detH^3*x21^2*r31_est^2*X(1)*y31*g1+8.*detH^2*x31*r21_est*x21*r31_est*X(1)^2)^(1/2));
  26. r = real(r12);
  27. MSx_y = -(h3)*(h2_est*r + 0.5*G_est);
  28. x = MSx_y(1);
  29. y = MSx_y(2);