How do I solve for the value of a constant to make a system consistent?

5 views (last 30 days)
I have the matrix Q = [0, 3; 1, 5; 0, 4; 1, -2] and the column c = [3; 6; 4; w]. I want to find a value of w that makes the system, Qx = c, consistent so that I can find the solution to the system.

Answers (2)

John D'Errico
John D'Errico on 15 Apr 2023
Edited: John D'Errico on 15 Apr 2023
syms w
Q = [0, 3; 1, 5; 0, 4; 1, -2]
Q = 4×2
0 3 1 5 0 4 1 -2
c = [3; 6; 4; w]
c = 
So you have a matrix Q, and a vector c. Can you find w, such that the problem Q*X=c has an exact solution? There are several ways to do this. Essentially, you want to find w so that the vector c can be represented EXACTLY as a linear combination of the columns in Q. One way might do that by finding the value of w that makes the matrix [Q,c] have rank 2.
[Q,c]
ans = 
I could probably find a way to do that. Alternatively, we might decide to just throw it at solve. Let it solve the problem. If there are any conditions we should worry about, it will tell us.
syms x [2 1]
xsol = solve(Q*x == c,'returnconditions',true)
xsol = struct with fields:
w: -1 x1: 1 x2: 1 parameters: [1×0 sym] conditions: symtrue
So the solution is as given, with w==-1.
Could I have done it differently? Probably. Look back at the matrix [Q,c]. For exampel, suppose I compute a reduced row echelon form? Under what conditions does it exist for this matrix?
rref([[Q,c].',eye(3)])
ans = 
And there we see rref tells us the matrix has rank 3, as long as w is NOT equal to -1. When w==-1, we have a singularity arise, so the original problem, thus [Q,c] will have rank 2 when w=-1. I'd bet I coud find other solutions too.

Torsten
Torsten on 15 Apr 2023
Moved: Torsten on 15 Apr 2023
Q = [0, 3; 1, 5; 0, 4];
c = [3; 6; 4];
x = Q\c;
w = [1,-2]*x
w = -1.0000

Community Treasure Hunt

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

Start Hunting!