function [deltaz,Rij,Hi,Hj,Pj] = Range_Bearing(Range,Bearing,RangeSigma,BearingSigma,Nmeas,Emeas,Nj,Ej,Njvar,Ejvar)
%Nmeas and Emeas are interpolated position of MR filter at time of
%measurement
%  Nj           z1=N1ego(C1);     % measurement = relative position             
%  Ej           z2=E1ego(C1);
%             Bearing=H1(C1);
%             Range=R1mod(C1);
%             RangeSigma=Rangesig*Range;
            R1z=[RangeSigma^2 0 ; 0 BearingSigma^2];
            R1x=[Njvar 0 ; 0 Ejvar];
            Bearing=zeroto2pi(Bearing);
            Hi=zeros(2,2);
            Hi(1,1)= cos(Bearing);   %range/N  also (Nhat-N1)/range
            Hi(1,2)= sin(Bearing);   %range/E  also (Ehat-E1)/range
            Hi(2,1)= -(Emeas-Ej)/Range^2;   %bearing/N
            Hi(2,2)=  (Nmeas-Nj)/Range^2;   %bearing/E
            Hj=-Hi;
            Pj=R1x;
            Rij=R1z;
            z=[Range;Bearing];
%             zhat=[sqrt((N31-z1)^2+(E31-z2)^2); zeroto2pi(atan2(E31-z2,N31-z1))];
            zhat=[sqrt((Nmeas-Nj)^2+(Emeas-Ej)^2); zeroto2pi(atan2(Emeas-Ej,Nmeas-Nj))];
            deltaz=[z(1)-zhat(1);-angdiff(z(2),zhat(2))];
end