diff --git a/matlab/DsgeSmoother.m b/matlab/DsgeSmoother.m
index f9e459e004d0d6794c8be35c8601b197201310e4..08b7011e93cc1d050444fe2c660f4e0645b2c891 100644
--- a/matlab/DsgeSmoother.m
+++ b/matlab/DsgeSmoother.m
@@ -255,7 +255,9 @@ if kalman_algo == 2 || kalman_algo == 4
                     [Pstar,Pinf] = compute_Pinf_Pstar(mf,ST,R1,Q,options_.qz_criterium);
                 else
                     Pstar = blkdiag(Pstar,H);
-                    Pinf  = blkdiag(Pinf,zeros(vobs));                    
+                    if ~isempty(Pinf)
+                        Pinf  = blkdiag(Pinf,zeros(vobs));                    
+                    end
                 end
                 %now reset H to 0
                 H   = zeros(vobs,vobs);
diff --git a/matlab/missing_DiffuseKalmanSmootherH3_Z.m b/matlab/missing_DiffuseKalmanSmootherH3_Z.m
index 24e6841cf9e7625231eb5b1b5366c483ecbd66fb..b03b13ee0ef02b5fcdaac162d20aadd079c1bbe8 100644
--- a/matlab/missing_DiffuseKalmanSmootherH3_Z.m
+++ b/matlab/missing_DiffuseKalmanSmootherH3_Z.m
@@ -122,7 +122,11 @@ end
 
 t = 0;
 icc=0;
-newRank = rank(Z*Pinf(:,:,1)*Z',diffuse_kalman_tol);
+if ~isempty(Pinf(:,:,1))
+    newRank = rank(Z*Pinf(:,:,1)*Z',diffuse_kalman_tol);
+else
+    newRank = rank(Pinf(:,:,1),diffuse_kalman_tol);
+end
 while newRank && t < smpl
     t = t+1;
     a(:,t) = a1(:,t);
@@ -156,7 +160,11 @@ while newRank && t < smpl
         end
     end
     if newRank
-        oldRank = rank(Z*Pinf(:,:,t)*Z',diffuse_kalman_tol);
+        if ~isempty(Pinf(:,:,t))
+            oldRank = rank(Z*Pinf(:,:,t)*Z',diffuse_kalman_tol);
+        else
+            oldRank = rank(Pinf(:,:,t),diffuse_kalman_tol);
+        end        
     else
         oldRank = 0;
     end
@@ -168,7 +176,11 @@ while newRank && t < smpl
     Pstar(:,:,t+1) = T*Pstar(:,:,t)*T'+ QQ;
     Pinf(:,:,t+1) = T*Pinf(:,:,t)*T';
     if newRank
-        newRank       = rank(Z*Pinf(:,:,t+1)*Z',diffuse_kalman_tol);
+        if ~isempty(Pinf(:,:,t+1))
+            newRank = rank(Z*Pinf(:,:,t+1)*Z',diffuse_kalman_tol);
+        else
+            newRank = rank(Pinf(:,:,t+1),diffuse_kalman_tol);
+        end
     end
     if oldRank ~= newRank
         disp('univariate_diffuse_kalman_filter:: T does influence the rank of Pinf!')