how to solve linear equation containing inverse of the matrix using backslash.

for example
z=(((inv(K1))*K2'*x)+((inv(K3))*K4'*xr)-((inv(K5))*K6'*phi)-((inv(K7))*F'))
how to represent this using backslash. Am getting an error
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN

Answers (2)

I guess that backslash won't help here, but of course you can write
z=K1\(K2'*x)+K3\(K4'*xr)-K5\(K6'*phi)-K7\F'
Best wishes
Torsten.
You can use pinv instead of inv here to remove the singularity problems, but the real issue is why one or more of these matrices are singular. Until you understand that, you will not know if pinv really is a valid solution. So use of pinv may simply be a resolution to the symptoms of your problem, as opposed to actually solving the real underlying problem.
By the way, I think you are over-using the parens here. Your code is virtually unreadable. That generally means you don't trust your knowledge of the order of operations in MATLAB, but the fix is SIMPLE. Just learn the order of operations, and your code will become wildly easier to read (and debug!)
z = pinv(K1)*K2'*x + pinv(K3)*K4'*xr - pinv(K5)*K6'*phi - pinv(K7)*F';

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

on 18 Jan 2016

Answered:

on 18 Jan 2016

Community Treasure Hunt

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

Start Hunting!