Matrix is close to singular or badly scaled. Results may be inaccurate.

1 view (last 30 days)
Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 1.986089e-23.
for k=1:40
a(k,1)=1;
a(k,2)=sin(W0*t(k));
a(k,3)=cos(W0*t(k));
a(k,4)=sin(3*W0*t(k));
a(k,5)=cos(3*W0*t(k));
a(k,6)=t(k);
a(k,7)=(t(k).^2);
b1(k,1)=V(k,1);
b2(k,1)=I(k,1);
end
a2=a';
a3=inv(a2*a);%warning come from this line itried a2\a but its not working and different here
a4=a3*a2;
Xv=a4*b1;
Xi=a4*b2;
thetav=atan(Xv(3,1)/Xv(2,1));
tv=rad2deg(thetav);
thetai=atan(Xi(3,1)/Xi(2,1));
ti=rad2deg(thetai);
z=((Xv(2)+(i*Xv(3)))/((Xi(2)+(i*Xi(3)))));
thetaz=atan(Xv(3,1)/Xv(2,1))-atan(Xi(3,1)/Xi(2,1));
tz=rad2deg(thetaz);
Z=abs(z);
  3 Comments
Walter Roberson
Walter Roberson on 24 Jun 2022
We will need your W0 and t values to test with.
Note that a2\a is entirely different than inv(a2*a) . a2\a is closer to inv(a2)*a
arian hoseini
arian hoseini on 24 Jun 2022
Edited: Walter Roberson on 24 Jun 2022
t=[0;0.0000;0.0001;0.0001;0.0001;0.0002;0.0003;0.0003;0.0004;0.0004;0.0004;0.0005;0.0006;0.0006;0.0006;0.0007;
0.0008;0.0008;0.0008;0.0009;0.0010;0.0010;0.0010;0.0011;0.0012;0.0012;0.0013;0.0013;0.0014;0.0014;0.0014
;0.0015;0.0015;0.0016;0.0017;0.0017;0.0018;0.0018;0.0019;0.0019]
W0=2*60*pi;

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 24 Jun 2022
You have enough duplicate t values that when you calculate "a" the rank does not reach 7; rank of a2*a does not reach 7, so your 7 x 7 matrix is singular.
format long g
t=[0;0.0000;0.0001;0.0001;0.0001;0.0002;0.0003;0.0003;0.0004;0.0004;0.0004;0.0005;0.0006;0.0006;0.0006;0.0007;
0.0008;0.0008;0.0008;0.0009;0.0010;0.0010;0.0010;0.0011;0.0012;0.0012;0.0013;0.0013;0.0014;0.0014;0.0014
;0.0015;0.0015;0.0016;0.0017;0.0017;0.0018;0.0018;0.0019;0.0019];
W0=2*60*sym(pi);
t = sym(t);
a = zeros(40, 7, 'sym');
for k=1:40
a(k,1)=1;
a(k,2)=sin(W0*t(k));
a(k,3)=cos(W0*t(k));
a(k,4)=sin(3*W0*t(k));
a(k,5)=cos(3*W0*t(k));
a(k,6)=t(k);
a(k,7)=(t(k).^2);
end
a2=a';
temp = a2*a;
vpa(temp,4)
ans = 
size(temp)
ans = 1×2
7 7
rank(temp)
ans =
6
ans =
6
size(a)
ans = 1×2
40 7
rank(a)
ans =
6
vpa(a, 4)
ans = 
a3 = inv(double(temp))
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.416580e-23.
a3 = 7×7
1.0e+00 * 67777253140.7658 -25603921793.069 -68225493381.5305 832812928.230255 448180506.302481 8712787650753.09 -4.57448194877832e+15 -25603921793.069 9760155248.57385 25770549709.5447 -316501185.988968 -166602910.913942 -3322436200988.51 1.72985152712877e+15 -68225493381.5305 25770549709.5447 68676781393.5081 -838262957.332607 -451227960.544581 -8769453942155.95 4.60468026606908e+15 832812928.230255 -316501185.988968 -838262957.332607 10274885.178035 5449251.51887214 107725990691.348 -56246480173259.8 448180506.302481 -166602910.913942 -451227960.544581 5449251.51887214 3047137.72603941 56657738350.4292 -30194231027123.4 8712787650753.09 -3322436200988.51 -8769453942155.95 107725990691.348 56657738350.4292 1.13100046719802e+15 -5.88676856525905e+17 -4.57448194877832e+15 1.72985152712877e+15 4.60468026606908e+15 -56246480173259.8 -30194231027123.4 -5.88676856525905e+17 3.08780937003526e+20

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Products


Release

R2016b

Community Treasure Hunt

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

Start Hunting!