How do I find out what specifically is causing the error "Matrix is close to singular or badly scaled" in the sgolay function?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm using the sgolay function from the Signal Processing toolbox to calculate some derivatives. The function is inside a loop as I feed it different parameters;
[~,g] = sgolay(poly_order, window_length).
However, it seems like for all or almost all of the iterations, I'm getting the warning
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 3.820809e-39.
> In sgolay (line 114)
where RCOND is not quite the same value each time. Line 114 in the function is
G = Q/R';.
I have a basic understanding of the error; the / command computes an inverse of a matrix, and the matrix cannot easily be inverted. However, I don't know what I can do differently to remove this warning. Can anyone help?
Réponses (1)
Image Analyst
le 7 Jan 2021
What are the poly_order and window_length you're using? I can see that if window_length is less than poly_order + 1, then you would have a problem. For example, you can't fit a parabola (order 2) with only 1 or 2 points. You'd need at least 3 and preferably more.
2 commentaires
Image Analyst
le 7 Jan 2021
Yes, like I said.
But the other problem is that if you're trying to fit a 31 order polynomial -- have you ever seen what happens when the polynomial order gets real high? You get all kinds of humps and instabilities between training points. I have no doubt that a polynomial like x^31 would cause problems. You shouldn't go more than about 3 or 4.
Attach your data if you need more help.
Voir également
Catégories
En savoir plus sur Linear Algebra dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!