Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 5.391064e-017.

Dear all,
During linear fitting involving regression matrix, i face the warning
Warning: Matrix is close to singular or badly scaled.
Results may be inaccurate. RCOND = 5.391064e-017.
and the estimates are erroneous.pls suggest how it can be resolved
Regards, Shravan.

Answers (1)

One likely cause for that warning message is that your explanatory variables are not linearly independent.
You need to provide a LOT more detail (ideally including the code that generated the warning) to get a more detailed answer.

4 Comments

Hi,
Pls find my code below. Among my estimates one that depends on A(:,2) is erroneous.Pls make ur suggestions. The warning can be found making use of sample data 1.
Regards,
Shravan.
clear all;
clc;
format long;
w=40;
wz=1.96e-3;
beta=(10*(pi/180));
s0=20000;
m=4;
%SAMPLE DATA 1%
t1=0.99;
t2=1.19;
%without scaling-1%
x1=0.0088;y1=-0.0032;
x1dot=-0.1305;y1dot=-0.3568;
x1dbldot=-14.453;y1dbldot=5.1796;
x2=-0.0046;y2=-0.0082;
x2dot=-0.3266;y2dot=0.1860;
x2dbldot=7.548;y2dbldot=13.1541;
%SAMPLE DATA 2%
% %without scaling-2%
% x1=0.0065;y1=0.0067;
% x1dot=0.2693;y1dot=-0.2579;
% x1dbldot=-9.9928;y1dbldot=-10.963;
% x2=0.0057;y2=-0.0075;
% x2dot=-0.3023;y2dot=-0.2293;
% x2dbldot=-9.1642;y2dbldot=12.329;
q1=0.5+2/pi*cos(w*t1)-2/(3*pi)*cos(3*w*t1)+(2/(5*pi))*cos(5*w*t1);
q2=0.5+2/pi*cos(w*t2)-2/(3*pi)*cos(3*w*t2)+(2/(5*pi))*cos(5*w*t2);
A=[-(y1dot),(0.5*q1*[(1+cos(2*w*t1))]*wz),(m*w^2*cos(w*t1+beta));-(x1dot),(0.5*q1*[(sin(2*w*t1))]*wz),(m*w^2*sin(w*t1+beta));-(y2dot),(0.5*q2*[(1+cos(2*w*t2))]*wz),(m*w^2*cos(w*t2+beta));-(x2dot),(0.5*q2*[(sin(2*w*t2))]*wz),(m*w^2*sin(w*t2+beta))];
g=[((m*y1dbldot)+(s0*y1));(m*x1dbldot)+(s0*x1);((m*y2dbldot)+(s0*y2));(m*x2dbldot)+(s0*x2)];
c=((A'*A))\(A'*g);
b=stepwisefit(A,g);
forgot to mention. the time for sample data 2 ..
t1=0.49;
t2=0.69;
and i am trying to estimate the parameters whose actual values are 50,1000 and 0.02
Please edit your original post adding the formatted code.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!