Solve for specific variable - like Excel's solver

5 ビュー (過去 30 日間)
Aaron Ashley
Aaron Ashley 2021 年 2 月 9 日
コメント済み: Star Strider 2021 年 2 月 10 日
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{:});

採用された回答

Star Strider
Star Strider 2021 年 2 月 9 日
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 件のコメント
Aaron Ashley
Aaron Ashley 2021 年 2 月 10 日
Thanks! That resolved the issue.
Star Strider
Star Strider 2021 年 2 月 10 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by