Help solving systems of linear equations

4 views (last 30 days)
Jesse Walters
Jesse Walters on 25 Jul 2018
Edited: Jesse Walters on 25 Jul 2018
I am trying to write a code to properly charge balance chemical reactions (complex redox reactions), and have run into some math issues. I am starting with a simple equation that I know the solution for:
I am trying to solve the equation Ax=B for the matrix A=[3 0 -2;4 2 -3;-1 4 0] when B=[0;0;0], the solution I am looking for is x=[4;1;6]. However, when I try to solve for x using x=A\B I get the following warning "Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 9.462128e-19." and the solution I get is x=[0;0;0].
How do I get a nonzero solution for my A matrix?
Thanks
  1 Comment
Jesse Walters
Jesse Walters on 25 Jul 2018
Edited: Jesse Walters on 25 Jul 2018
I solved it, if you change the matrixes to A=[3 0 -2;4 2 -3;-1 4 0;0 1 0] and B=[0 0 0 1] then it's not overdetermined and can actually be solved.

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!