problem checking rank of a matrix

Hello,
during an optimization of a function I simulate a matrix xx and a matrix yy. The dimensions are n times 3 for xx and n times 1 for yy. Subsequently I want to run the regression yy=beta*xx+e by using the backslash operator.
However in some cases I get the warning:
{Warning: Rank deficient, rank = 2, tol = 1.1852e-013.}
To avoid this I implemented an if-loop that forbids the computer to run the regression if rank(xx)<3. However this does not work. There are cases where Matlab runs the regression nevertheless and displays the warning.
Do you have any idea how to solve the problem?

댓글 수: 4

Walter Roberson
Walter Roberson 2011년 12월 8일
There is no such thing as an if loop.
the cyclist
the cyclist 2011년 12월 8일
It is difficult to diagnose code errors without seeing the code. Are you able to post your code?
Sean de Wolski
Sean de Wolski 2011년 12월 8일
The day no if loop survived!
HansWurst
HansWurst 2011년 12월 14일
I added the code below

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

답변 (1개)

HansWurst
HansWurst 2011년 12월 12일

0 개 추천

Here is the code with alphahat and betahat as regression parameters:
if rank(xx)<3
alphahat = 0;
betahat = 0;
else
beis = xx\yy;
alphahat = -2*beis(3);
alphahat(alphahat<0)=0;
betahat = beis(2);
end

카테고리

질문:

2011년 12월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by