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

通讯/手机编程

开发平台:

Matlab

  1. function weight=weights_cal(bx,by,d)
  2. %
  3. %
  4. %
  5.         L_bx=length(bx);
  6.         
  7.         ang=0:pi/100:2*pi;
  8.         figure,hold on,grid on
  9.         for k=1:L_bx
  10.             plot(bx(k)+d(k)*cos(ang),by(k)+d(k)*sin(ang),'b','linewidth',2)
  11.         end
  12.         plot(bx,by,'r^','linewidth',2)
  13.         com=combntns(1:L_bx,2);
  14.         sz=size(com);
  15.         
  16.         int_x=[];int_y=[];
  17.         clear k;
  18.         for k=1:sz(1)
  19.             [ex,ey]=cir_cir_intersection([bx(com(k,1)) bx(com(k,2))],[by(com(k,1)) by(com(k,2))],[d(com(k,1)) d(com(k,2))]);
  20.             int_x=[int_x real(ex)];
  21.             int_y=[int_y real(ey)];
  22.             plot(ex,ey,'o','linewidth',2)
  23.         end
  24.         
  25. %         plot(int_x,int_y,'o','linewidth',2)
  26.         
  27.         
  28.         flag=[];        cn=0;
  29.         rint_x=[];rint_y=[];
  30.         
  31.         clear k;
  32.         for k=1:length(int_x);
  33.             for ki=1:L_bx
  34.                 if (int_x(k)-bx(ki))^2+(int_y(k)-by(ki))^2 <= (1+1e-3)*d(ki)^2;
  35.                     flag(ki)=1;
  36.                 end
  37.             end
  38.             if sum(flag)==L_bx
  39.                 cn=cn+1;
  40.                 rint_x(cn)=int_x(k);
  41.                 rint_y(cn)=int_y(k);
  42.             end
  43.             flag=[];
  44.         end
  45.         
  46.         plot(rint_x,rint_y,'ro','linewidth',2)
  47.         axis([-4000 4000 -4000 4000])
  48.         
  49.         weight=[];
  50.         
  51.         if length(rint_x)< L_bx
  52.         clear k
  53.         for ko=1:L_bx
  54.             dis=sqrt((rint_x-bx(ko)).^2+(rint_y-by(ko)).^2);
  55.             [m,mi]=min(dis);
  56.             weight(ko)=dis(mi)/d(ko);
  57.         end
  58.                 
  59.         weight;
  60.         9;