How to solve an equation that is using the function min()

Hi,
I've got this system below and i would try to find x, but I don't know how to do this, has someone an easyy way to solve it ?
thanks
P = [1,2,3,2,1];
C = [3,4,5,5,4];
t = 0.4;
syms x
equation = x * sum(P) * t == sum(min(x * P ,C));
S = solve (equation, x);

回答 (1 件)

Star Strider
Star Strider 2019 年 12 月 27 日

0 投票

The Symbolic Math Toolbox is not likely to be able to do what you want.
Try this:
P = [1,2,3,2,1];
C = [3,4,5,5,4];
t = 0.4;
equation = @(x) x * sum(P) * t - sum(min(x .* P ,C));
x0 = 100;
[S,fval] = fsolve (equation, 100);
Choose the value for ‘x0’ that gives you the result you want. (The initial estimate is important.)

2 件のコメント

Star Strider
Star Strider 2019 年 12 月 27 日
Alan Lauraux’s Answer moved here —
Thank you very much, Star Strider,
it works fine
Best regards
Alan
Star Strider
Star Strider 2019 年 12 月 27 日
My pleasure.
If my Answer helped you solve your problem, please Accept it!

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

カテゴリ

ヘルプ センター および File ExchangeSymbolic Math Toolbox についてさらに検索

質問済み:

2019 年 12 月 27 日

コメント済み:

2019 年 12 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by