Matrix from measured data is singular, what could be the reason?

Unfortunatelly I don't get a solution for the LSE function:
C=(A'*A)\(A'*B)
with A=[i x 5], B=[i x1]
The matrix A'*A is singular. The matrixes A and B contain functions with measured data. The measured data has been cleaned and filtered before beeing utilized.
Does anybody know, what could be the reason? Maybe because oversampling?
rank(A'*A)=4
A'*A = 5×5
8.5012e+04 -4.9210e+03 1.4934e+01 -1.1823e+03 2.3363e+01
-4.9210e+03 7.2070e+02 -1.3927e+00 1.1026e+02 -1.0357e+00
1.4934e+01 -1.3927e+00 1.3082e-02 -1.0357e+00 5.2241e-01
-1.1823e+03 1.1026e+02 -1.0357e+00 8.2000e+01 -4.1359e+01
2.3363e+01 -1.0357e+00 5.2241e-01 -4.1359e+01 4.1082e+01

4 Comments

The measured data has been cleaned and filtered before beeing utilized
How was it filtered? Certain kinds of filtering can reduce the degrees of freedom and so end up reducing the rank.
Thank you for the quick response.
% Datafiltering, pos. slope only and no Inf
s=isinf(dUdj)==0 & dUdj>0;
dUdj=dUdj(s)';
Maybe your coefficients in the function to be fitted are not independent ?
this LSE method and the equations should be right- they are the same as in the literature. The only difference are the measured variables (U,j) in the functions. The matrix A consists of:
A=[ dU1/dj1 k1/j1 k2 -1 j1
dU2/dj2 k1/j2 k2 -1 j2
.....
dUi/dji k1/ji k2 -1 ji ]
I have allready tried out a different numerical method mapping the slope dU/dj to the midpoint, using xp=x(1:end-1)+diff(x)./2 but it doesnt help.

Sign in to comment.

Answers (3)

Could you try the normalization similar to my answer here?

17 Comments

Could you try and tell me what this command give
[AN,C,S] = normalize(A,'medianiqr');
C = ((AN+C./S)\B) ./ S.'
Can you post
all(isfinite(A(:)))
all(isfinite(B(:)))
[AN,C,S] = normalize(A,'medianiqr');
C
S
ans = logical
1
ans = logical
1
C = 1×5
5.7328e-01 -4.3289e-02 1.5216e-02 -1.0000e+00 3.5217e-01
S = 1×5
7.4992e+00 2.3536e+00 0 0 1.0010e+00
I see now, the reason for issue is much obvious and simpler than I though: Your matrix has 2 constant columns #3 and 4.
They are dependent vectors, that's why the matrix has rank 4. You must not have both in your model.
May be a single column of (k2-1) instead of 2 columns of k2 and -1? Who knows what is the model is?
Thank you Bruno. It was actually my first thought, but the equations are correct. It seems to have something to do with the measured values. maybe the sample rate of the measured Ui and Ii is to high, which causeds this numerical problem
No. You try to fit a model with dependent parameters.
In your case, it has the form
a*dU/dj + b*k1/j + c*k2 - d +e*j = measured data
c and d are dependent parameters because both represent the constant in your model.
@Anna B. Your first though is correct your other thoughs are not.
Given k2, says == 10 ,You cannot hope to be able find c3 and c4 such that
c3*k2 - c4 = 90
That what you have with your inversion system.
c3 = 9, c4 = 0 ?
c3 = 10, c4 = 10 ?
c3 = 11, c4 = 20 ?
c3 = 0, c4 = -90 ?
I will show you one example. I have only 3 unknown- so there should be a solution.
I don't know the book but the element (3,1) of this matrix is not equal to (3,i) for i >= 2. Not in your case.
" I have only 3 unknown- so there should be a solution. "
You must tell a consistent story, your algebra system solve for 5 unknowns (not 3), with mostly #3 and #4 that are redundant.
And RT/(2*F) and Rtheta/(2*F) in the second and third column is the same ?
If that is the case this book is wrong, twice.
its a misspelling theta=T
I don't believe this since if it were a misspelling, the error the authors had made to present a fitting model with two times estimating the constant of the model would be even bigger.
There are also a Rtheta/2F on the RHS. If Cx(3,1) is misspelling of Rtheta/2F why the author splits in both sides? Just wonder...
This source is trustworth, but I will check the equations again. Hopefully this is the reason.
Thank you very much!
Yes, we don't doubt that the source is trustworthy because we doubt that it's a misspelling.

Sign in to comment.

syms dj1 dj2 dji dU1 dU2 dUi j1 j2 ji k1 k2
A=[ dU1/dj1 k1/j1 k2 -1 j1
dU2/dj2 k1/j2 k2 -1 j2
dUi/dji k1/ji k2 -1 ji ]
A = 
t = A'*A
t = 
size(t)
ans = 1×2
5 5
rank(t)
ans = 3
A'*A is a linear combination of A with something (that happens to be A' ) . Linear combinations of a matrix cannot increase the rank, so A'*A cannot have higher rank than A has -- which is 3 because A has only 3 rows.

2 Comments

I guess she wants to write
dU1dj1
dU2dj2
...
dUidji
...
Not literally 3 rows.
my fault, sorry... the matrix has i rows.

Sign in to comment.

In no place in this thread have I seen the matrix A. I've seen various versions of it however, with various numbers of rows. I've seen you compute the product A'*A, and give the result of that. But I would strongly conjecture that A has only 4 rows and 5 columns, because in different places, you seem to show matrices with a different number of rows. And you don't seem to think the number of rows is pertinent.
In fact, the size of the matrix A itself is HUGELY pertinent. Why?
When you form the product of two matrices, the rank of the product can never be larger then the rank of either of the components in the product. It will be the same rank as the smaller of the two ranks. In your case, you tell us that A'*A has rank 4, and you show a matrix that is 5x5.
This tends to suggest that A itself has rank 4. And most likely, that suggests that A itself was only a 4x5 matrix, so it had only 4 rows. The rank of a 4x5 matrix will never be larger than 4. it could sometimes be less than 4. But NEVER larger. In that case, A'*A will ALWAYS be a singular matrix. It can never have a rank higher than 4.
I won't even get into the next question, to ask why in the name of god are you using the formula
X = (A'*A)\(A*B);
That just creates more numerical problems. The solution in MATLAB is:
X = A\B;

2 Comments

The matrix A has i rows and 5 columns (each row has the measured Ui and Ii in it). It is a numerical problem for shure- but I can't find the reason...
p.s.
with C=A\B, i get the problem:
"Warning: Rank deficient, rank = 4, tol = 5.308769e-12."
C = 5×1
3.9325e-03
-1.1491e-03
0
3.9130e-02
5.5652e-01
with C=(A'*A)\(A'*B), i get the problem:
"Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 2.079731e-22."
C = 5×1
3.9325e-03
-1.1491e-03
-1.9817e+00
8.9764e-03
5.5652e-01
When A has i rows and 5 columns, then rank(A'*A) is at most min(i, 5)

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 28 Apr 2022

Commented:

on 29 Apr 2022

Community Treasure Hunt

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

Start Hunting!