weights_cal.asv
资源名称:TOA_uwb.rar [点击查看]
上传用户:doryuen
上传日期:2013-10-30
资源大小:23k
文件大小:2k
源码类别:
通讯/手机编程
开发平台:
Matlab
- function weight=weights_cal(bx,by,d)
- %
- %
- %
- L_bx=length(bx);
- ang=0:pi/100:2*pi;
- figure,hold on,grid on
- for k=1:L_bx
- plot(bx(k)+d(k)*cos(ang),by(k)+d(k)*sin(ang),'b','linewidth',2)
- end
- plot(bx,by,'r^','linewidth',2)
- com=combntns(1:L_bx,2);
- sz=size(com);
- int_x=[];int_y=[];
- clear k;
- for k=1:sz(1)
- [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))]);
- int_x=[int_x real(ex)];
- int_y=[int_y real(ey)];
- plot(ex,ey,'o','linewidth',2)
- end
- % plot(int_x,int_y,'o','linewidth',2)
- flag=[]; cn=0;
- rint_x=[];rint_y=[];
- clear k;
- for k=1:length(int_x);
- for ki=1:L_bx
- if (int_x(k)-bx(ki))^2+(int_y(k)-by(ki))^2 <= (1+1e-3)*d(ki)^2;
- flag(ki)=1;
- end
- end
- if sum(flag)==L_bx
- cn=cn+1;
- rint_x(cn)=int_x(k);
- rint_y(cn)=int_y(k);
- end
- flag=[];
- end
- plot(rint_x,rint_y,'ro','linewidth',2)
- axis([-4000 4000 -4000 4000])
- weight=[];
- if length(rint_x)< L_bx
- clear k
- for ko=1:L_bx
- dis=sqrt((rint_x-bx(ko)).^2+(rint_y-by(ko)).^2);
- [m,mi]=min(dis);
- weight(ko)=dis(mi)/d(ko);
- end
- weight;
- 9;