Positive definite solution

i need to solved for different values of gama until its lowest value, which gives a positive definite solution for P is found, so i am using all(eig(P)>0) like the equation below:
is this right?
gama=100000;
for i=1:2000;
P = inv(inv(P)+M'*inv(R)*M-gama^(-2)*eye(4));
E=eig(P_cov);
if all(eig(P))>0) %%(all eigenvalues must be positive)
gama=gama/2;
else
break;
end
end
P = inv(inv(P)+M'*inv(R)*M-gama^(-2)*eye(4));
is this correct?

 채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 23일

1 개 추천

If the eigenvalues are all positive, you change gama, exiting the loop when they are not all positive. That means that at the end the gama you get out will be such that the eigenvalues are not all positive. This does not satisfy the stated conditions.

댓글 수: 3

dab483
dab483 2011년 11월 23일
yes. that's what i am facing right now. any idea how do i correct them.
Walter Roberson
Walter Roberson 2011년 11월 23일
gama=100000;
oldgama = gama;
...
if all(eig(P))>0) %%(all eigenvalues must be positive)
oldgama = gama;
gama=gama/2;
else
break;
end
Then right after the end of the "for" loop,
gama = oldgama;
dab483
dab483 2011년 11월 24일
Thank you. It satisfy the stated conditions.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sean de Wolski
Sean de Wolski 2011년 11월 23일

1 개 추천

Use a second variable and only update it if the eigenvalues are all positive. When you exit the loop it will be the last set of all positive eigenvalues.

댓글 수: 1

dab483
dab483 2011년 11월 23일
Can you show it a litle bit.. i'm blank right now.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by