Conversion of linear equations to form Ax=b

Hello everyone,
I have the following equations:
syms t u v w x y z
intersection_a = -t + w + x == 100;
intersection_b = t - u == 100;
intersection_c = v + w - y - z == 0;
intersection_d = u + v == 40;
I can convert it to form of Ax=b using equationsToMatrix(). But my question is if I have t = 100 and w+x+y = 100, then does the equation change? Do I need to put t = 100 etc in these equations? If I will, then there will be no t in equations. How I will be able to write then it in form of Ax= b where x = [t u v w x y z] '?
Thanks in advance.

 Accepted Answer

You have only 4 equations, but there are 6 unknowns. So, the linear system is clearly rank-deficient.
syms t u v w x y z
t = 100;
intersections = [-t + w + x == 100, ...
t - u == 100, ...
v + w - y - z == 0, ...
u + v == 40];
vars = [u, v, w, x, y, z];
[A, b] = equationsToMatrix(intersections, vars)
A = 
b = 
x = linsolve(A, b)
Warning: Solution is not unique because the system is rank-deficient.
x = 

6 Comments

I got it. But how can I use w+x+y = 100 in it?
@aliza mustafa, Even adding one more equation to solve for 6 unknowns, the system is still rank-deficient.
syms t u v w x y z
t = 100;
intersections = [-t + w + x == 100, ...
t - u == 100, ...
v + w - y - z == 0, ...
u + v == 40, ...
w + x + y == 100];
vars = [u, v, w, x, y, z];
[A, b] = equationsToMatrix(intersections, vars)
A = 
b = 
x = linsolve(A, b)
Warning: Solution is not unique because the system is rank-deficient.
x = 
A unique solution exists if and only if,
  1. the number of unknowns and the number of equations are equal,
  2. all equations are consistent, and
  3. there is no linear dependence between any two or more equations, that is, all equations are independent.
I see. So it means I need to write w + y + z = 100 as equation in intersection list. I got it.Thank you so much :)
To get a unique solution, you will have to define as many equations as there are variables.
If you have more variables than equation, you can solve for as many variables as there are equations.
These variables are expressed in terms of the remaining variables and can be chosen freely.
In the below example you solve for u,v,w,x in terms of t,y,z.
syms t u v w x y z
intersections = [-t + w + x == 100, ...
t - u == 100, ...
v + w - y - z == 0, ...
u + v == 40. ...
w + x + y == 100];
vars = [u, v, w, x, y];
sol = solve(intersections,vars)
sol = struct with fields:
u: t - 100 v: 140 - t w: z - 140 x: t - z + 240 y: -t
Thanks for sharing about solve() function. Can you please suggest me that is it alright to add w + y + z = 100 as an equation in intersections[] ?
If it has to be satisfied, it has to be included. Why do you ask for this specific equation ? Is it different from the others ?

Sign in to comment.

More Answers (0)

Categories

Asked:

on 15 Sep 2022

Edited:

on 15 Sep 2022

Community Treasure Hunt

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

Start Hunting!