-
Notifications
You must be signed in to change notification settings - Fork 3
/
ComputeR.m
executable file
·49 lines (35 loc) · 1.49 KB
/
ComputeR.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function R = ComputeR(xkk,Skk)
global xxx;
for i = 1: length(lmd0),
for j = 1: length(b0),
theta = [lmd0(i),b0(j)]; % fetch grid point (lmd, b)
lmd = theta(1);
b = theta(2);
%%% Calculate measurement covariance: R
Gamma = diag([c/2,c/(2*fc)]);
I11 = 1/(2*(2*pi)^2*lmd^2) + 2*b^2*lmd^2;
I12 = 2*b*lmd^2;
I22 = lmd^2/2;
I = (2*pi)^2*snr*[I11, I12; I12, I22];
R = Gamma*inv(I)*Gamma'; % warning may appear for singular I?? Eq.(7)
%%% Approximate cost function: J(\theta)
% z_p = mvg(z_k,P_zz,N_z);
%
% for m = 1: N_z;
% %% Calculate P_kk
%
% [xkk,Skk] = Update(xkk1,Skk1,z_p,R);
%
%
% J_temp(m)= trace(Lambda*Skk*Skk');
%
% end
J(i,j)= trace(Lambda*Skk*Skk');
J(i,j) = mean(J_temp); % store the cost for each grid point
[ind_x,ind_y] = find(J == min(min(J))); % find the minimum of J
end
end
theta_new = [lmd0(ind_x),b0(ind_y)]; % using theta_new as the new waveform
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Compute R according to theta_new again
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%