Cutting stuff
I usually use logical indexes to cut matrices into parts. I think it is better. instead of doing this
% cut the P matrix into parts
P11 = P( 1:N , 1:N );
P12 = P( 1:N , N+1:2*N );
P21 = P( N+1:2*N , 1:N );
P22 = P( N+1:2*N , N+1:2*N );
i specify a logical index for each column and each row
% column 1
c1 = [true(1,1:N), false(1,N+1:2*N)];
% column 2
c2 = ~c1;
% Cut the matrix
P11 = P(c1,c1);
P12 = P(c1,c2);
P21 = P(c2,c1);
P22 = P(c2,c2);