Solving A Matrix Equation Symbolically

I am trying out Matlab, and am currently trying to solve a simple matrix equation that I made up. Here is my script:

syms b1 b2 b3 

A = [1 2; 2 1; 3 3];

B = [b1; b2; b3];

X = linsolve(A, B)

The output is

Warning: System is inconsistent.
Solution does not exist. 

X =

 Inf
 Inf

What might I be doing wrong?


EDIT:

Okay, I was able to fix it. However, now I am trying to accomplish something else.

Here is what I type in:

C = [1 2 3 b1; 2 1 6 b2; 3 3 5 b3];

rref(C)

and the result is:

[ 1, 0, 0, (3*b3)/4 - b2/12 - (13*b1)/12]
[ 0, 1, 0,               (2*b1)/3 - b2/3]
[ 0, 0, 1,            b1/4 + b2/4 - b3/4]

However, what I would like is to have create a matrix such that the third row is 0 = f(b1, b2, b3), that is, I would like the third row to be 0 on the LHS and the RHS only involves b1, b2, and/or b3. How might I go about this? I tried making every entry into a variable, but this didn't seem to work.

This is what the output was:

[ 1, 0, 0,  (a2*a6*b3 - a3*a5*b3 - a2*a9*b2 + a3*a8*b2 + a5*a9*b1 - a6*a8*b1)/(a1*a5*a9 - a1*a6*a8 - a2*a4*a9 + a2*a6*a7 + a3*a4*a8 - a3*a5*a7)]
[ 0, 1, 0, -(a1*a6*b3 - a3*a4*b3 - a1*a9*b2 + a3*a7*b2 + a4*a9*b1 - a6*a7*b1)/(a1*a5*a9 - a1*a6*a8 - a2*a4*a9 + a2*a6*a7 + a3*a4*a8 - a3*a5*a7)]
[ 0, 0, 1,  (a1*a5*b3 - a2*a4*b3 - a1*a8*b2 + a2*a7*b2 + a4*a8*b1 - a5*a7*b1)/(a1*a5*a9 - a1*a6*a8 - a2*a4*a9 + a2*a6*a7 + a3*a4*a8 - a3*a5*a7)]

Answers


You are defining a system of equations with 3 equations and only 2 unknowns. In general, if the number of equations is greater than the number of unknowns then almost always there will not be a solution to the system. Try A = [1 2; 2 1] and B = [b1; b2] and you should get an answer because then you have the same number of equations as unknowns, in which case the solution to the system will exist, and also be unique provided that A is invertible.


I don't know which kind of output you did expect, but using numeric functions for symbolic input is somehow strange.

Try:

b=sym('b',[3,1])
x=sym('x',[2,1])
f=solve(A*x==B)

Need Your Help

Developing ASP.NET MVC UI Extensions - best approach

jquery asp.net-mvc user-controls

What are the best practices in developing rich UI extensions for ASP.NET MVC (I mean asynchronous / partial loading, slick effects, skinning etc) ? I saw that Telerik has an MVC suite of extensions...

Loaded the nib but didn't get a UITableView

ios objective-c uitableview uisearchbar

I have been following this tutorial on YouTube (part 1 and part 2).