How do I write an equation when I have both a variable and its value for one side
Mostra commenti meno recenti
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.
Risposte (1)
Doddy Kastanya
il 6 Gen 2021
0 voti
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)'.
1 Commento
Walter Roberson
il 6 Gen 2021
(coef matrix) \ [x;y;z] would be better mathematically
Categorie
Scopri di più su Linear Algebra in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!