Matrix is singular or badly scaled. Please help

I've been working on the attached code for quite some time now and I think I'm close. I keep getting the following warning:
In hopefullyBetterProject (line 55) Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
In hopefullyBetterProject (line 74) Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
Both lines are the same matrix operation:
someVariable = step*(Mmat\Qmat);
I'm not sure what's going wrong here and I think I'm starting to lose what's left of my marbles. Any help with solving or approaching this error would be amazing. Thanks!

Answers (1)

Your values are getting larger and larger in magnitude as you go. When you reach ii = 6, the second Qmat has involves adding numbers large enough that infinity is returned. The result of the \ operator that follows that will involve NaN. In the next iteration of the for loop, when ii = 7, those NaN propagate and give you an all-NaN matrix; at that point you get the warning because the NaN vector cannot be inverted.

Categories

Tags

Asked:

on 7 May 2017

Answered:

on 8 May 2017

Community Treasure Hunt

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

Start Hunting!