issue with lsqlin versus regress

조회 수: 5 (최근 30일)
hdg D
hdg D 2014년 10월 3일
댓글: hdg D 2014년 10월 3일
Hello, I am bit confused why lsqlin and regress yield different results. Here is a worked example. The lsqlin does not solve at all maybe I am missing something in the specification
load carsmall
x1 = Weight;
x2 = Horsepower; % Contains NaN data
y = MPG;
X = [ones(size(x1)) x1 x2 x1.*x2];
b = regress(y,X) % Removes NaN data
x0 = 0.1*ones(size(X,2),1);
options = optimoptions('lsqlin','Algorithm','active-set');
xx = lsqlin(X,y,[],[],[],[],[],[], x0, options)
b =
60.7104
-0.0102
-0.1882
0.0000
xx =
0
0
0
0
  댓글 수: 4
Matt J
Matt J 2014년 10월 3일
What do you get from
>>cond(X)
hdg D
hdg D 2014년 10월 3일
you are right! doh! nearly singular matrix!

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by