How do I write an equation when I have both a variable and its value for one side

1 view (last 30 days)
Here's an example:
say we have
x=a+b+c;
y=ab;
z=c-a;
Three equations, three variables, easy. However, to get numerical answers, I'm gonna need numerical values for x,y,z, which will be user input. If for example, I know that x=5, how would I write that? x is already defined as a+b+c. can I just redefine it?
mind you later on, I will have other equations that will also involve x,y,z, which is why I'm hesitant to just use a function.

Answers (1)

Doddy Kastanya
Doddy Kastanya on 6 Jan 2021
The problem as you presented is non-linear and would need some manipulations before you can solve it. However, if "y=a+b" instead of "y=ab", then you can use MATLAB to find the values of a, b, and c, given the values of x, y, and z. You just need to write them in the following fashion, to put the known values on the right hand side:
a + b + c = x
a + b = y
-a + c = z
You have a coefficient matrix of [1 1 1; 1 1 0;-1 0 1] which is invertible. You can find the values of a, b, and c, by simply doing inv(coef matrix)*(x y z)'.

Categories

Find more on Historical Contests 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!