% Check Juu is positive definite or not
%Juu = [1861 -1135 -17.9;-1135 1160 12.83;...         % open loop
 % -17.9 12.83 1.84];
%Juu = [1873 -1126 -17.72;-1126 1161 12.50;...      % value from Central diffrence close
  %-17.72 12.50 1.9609];
%Script for checking positive definite of a matrix
 [m,n]=size(Juu); 
    if m~=n,
       error('Juu is not Symmetric');
    end
    
    %Test for positive definiteness
    x=1; %Flag to check for positiveness
    for i=1:m
       subJuu=Juu(1:i,1:i); %Extract the upper left kxk submatrix
       if(det(subJuu)<=0); %Check wheather the determinent of the kxk submatrix is +ve
            x=0;
            break;
        end
    end
    
    if x
        display('Juu Matrix is Positive definite');
    else
       display('Juu Matrix is NOT positive definite');
    end      
