Regarding implementation of kalman filter I am not sure if this is the right stack exchange but please say so if it isn't and I will try to post my question in the relevant place.
My questions is regarding the implementation of a discrete time Kalman filter assuming the time update occurs much more often than measurement update. I'll be specifically looking at the covariance propagation and Kalman gain equations.
Given a D.T. KF with the following state space model:
$$
\hat{x}_{k+1} = F \hat{x}_k + G \omega_k
$$
$$
\hat{y}_k = C \hat{x}_k + \upsilon_k
$$
and assuming $\hat{x}^-(0)$ and $P^-(0)$ are known as well as the process and measurement noise intensities (Q and R respectively) the relevant equations are:
Gain update:
$$
K = P^-C^T (CP^- C^T + R)^{-1}
$$
Measurement update
$$
P^- = F P^+ F^T + Q
$$
Time Update:
$$
P^+ = (I-KC)P^-
$$
The difficulty I am having is with respect to implementation and how to properly initialize. A pseudo code example of what I think should be done is the following:
% Pp = P-
% Pu = P+
Pp = P0;                                       % Initializing P-
for i=1:N                                      % N = number of measurement updates
    for j=1:m                                  % m = number of time updates in one measurement update
        Pp = F*Pu*F' + Qd;                     % covariance prop
        K = [K, Pp*C'*(R + C*Pp*C')^(-1)];     % update gain
        cnt = cnt + 1;
    end
    Pu = (eye(nx) - K(:,cnt)*C)*Pp;            % measurement update
    cnt = cnt + 1;
end

But this has the problem that the first iteration Pp cannot compute because there has yet to be a measurement update. This is easily solved by forcing a measurement update before any time updates. Maybe it's just me but it seems kind of incorrect to NEED a measurement update before any time updates.
 A: Your code is wrong for a number of reasons. First you do not want to compute m times the same value of Pp:
Pp = F*Pu*F' + Qd; %this will be the same value computed over and over

since F,Pu and Q_d don't change. I assume you meant to write
Pp = F*Pp*F' + Qd;

Let's rewrite your outer loop body as:
for j=1:m                
        Pp = F*Pp*F' + Qd;                     
        K = [K, Pp*C'*(R + C*Pp*C')^(-1)];     
        cnt = cnt + 1; 
end

Your issue is now almost fixed. Let's set set m=1 as the issue will hold regardless of m:
Pp = P0
for i=1:N 
   Pp = F*Pp*F' + Qd;                     
   K = [K, Pp*C'*(R + C*Pp*C')^(-1)];
   Pu = (eye(nx) - K(:,cnt)*C)*Pp;  
   cnt = cnt + 1   
end

the code will run correctly for the first loop, but for i=2 step 
Pp = F*Pp*F' + Qd; will be wrong (correctness of value computed - it will still run). We fix this with the following
Pu = P0
for i=1:N 
   Pp=Pu
   Pp = F*Pp*F' + Qd;                     
   K = [K, Pp*C'*(R + C*Pp*C')^(-1)];
   Pu = (eye(nx) - K(:,cnt)*C)*Pp;
   cnt = cnt + 1     
end

Now your Kalman filter matches the classic definition. Note that Pp is usually defined as the predict covariance and Pu update covariance. For initializing the Kalman filter Pu is defined (and not Pp like you did). Putting it all together:
Pu = P0
for i=1:N 
   Pp = Pu
   for j=1:m
       Pp = F*Pp*F' + Qd;                     
       K = [K, Pp*C'*(R + C*Pp*C')^(-1)];
       Pu = (eye(nx) - K(:,cnt)*C)*Pp;    ]
       cnt = cnt + 1 
    end
    Pu = (eye(nx) - K(:,cnt)*C)*Pp;
    cnt = cnt + 1
end

