function [gain]=new_KS_EnKF_gain_matrix(X,h,h_pr,X_pr,Np) t1=1; t2=t1+1e-10; % pseudo-time X_prt=X-repmat(mean(X,2),1,Np); h_prt=h-repmat(mean(h,2),1,Np); R1=1e-200;R2=1e-200; % noise intensity X_prt_til=(repmat(mean(X,2),1,Np)*t2-repmat(mean(X_pr,2),1,Np)*t1); h_prt_til=h*t2-repmat(mean(h_pr,2),1,Np)*t1... -(repmat(mean(h,2),1,Np)-repmat(mean(h_pr,2),1,Np))*t2; a1=0.8; G1=1/Np*X_prt*h_prt_til'/(a1*(h_prt*h_prt')*1/(Np-1)+(1-a1)*R1*eye(size(h_prt,1))); G2=1/Np*X_prt_til*h_prt'/(a1*(h_prt*h_prt')*1/(Np-1)+(1-a1)*R2*eye(size(h_prt,1))); gain=(G1+G2); % gain matrix end