Solve for specific variable - like Excel's solver
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aaron Ashley
am 9 Feb. 2021
Kommentiert: Star Strider
am 10 Feb. 2021
I would like to determine the value of a variable within a complex equation. For example, let's say my equation is y = mx + b. This is simplified but still useful. I know what y is, but I don't know what x is. I want to determine which value of x gives the known value of y. As another example, I am trying to tell MATLAB how to act like the Excel Solver add-in.
I have tried to follow various guides online and used simple equations as outlined below. I encounter the same error and I'm not sure what else I might try. How might I go about this process?
My example code and the corresponding error follows:
>> syms x;
t = solve('2*x+6==0', 'x');
Error using solve>getEqns (line 418)
List of equations must not be empty.
Error in solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
0 Kommentare
Akzeptierte Antwort
Star Strider
am 9 Feb. 2021
The problem is with the single (or any other) quotes.
Remove them, and then:
syms x
t = solve(2*x+6==0, x)
produces:
t =
-3
.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!