Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I solve an equation using constants defined outside the solve command?

1 回表示 (過去 30 日間)
Lynn
Lynn 2014 年 4 月 8 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, I have the following code:
solve('(.5*Tp(i)+ .5*T1)/(Tp(i)/(2*pi)) = x - e(i)*sin(x)' , '-pi/2 < x < pi/2');
where Tp, and e are taken from arrays. I get the following error:
Warning: Could not extract individual solutions. Returning a MuPAD set object. > In solve>assignOutputs at 104 In solve at 87.
When I plug in manually the values for Tp, and e, I get an answer, so the problem seems to be the face that these constants are defined outside the prompt command. How can I fix this? Note that I have an old version of matlab, so I can't use some 2014a commands. Thanks for you help!

回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 4 月 8 日
syms x
solve( (.5*Tp(i)+ .5*T1)/(Tp(i)/(2*pi)) = x - e(i)*sin(x) , '-pi/2 < x < pi/2');
If that gives you trouble then
syms x
solve((.5*Tp(i)+ .5*T1)/(Tp(i)/(2*pi)) - (x - e(i)*sin(x)) , '-pi/2 < x < pi/2');
  2 件のコメント
Lynn
Lynn 2014 年 4 月 8 日
The first one gave me the same error, and the second one gave me the error: Warning: 2 equations for 1 variables. Explicit solution could not be found.
Walter Roberson
Walter Roberson 2014 年 4 月 8 日
When you call solve() from the MATLAB level, each part must be either a variable name, or a name/value pair, or a symbolic equation. Your '-pi/2 < x < pi/2' is not any of those: it is a symbolic inequality.
You could try using assumptions with assume(), or you could call into the symbolic engine's solve() function using
feval(symengine, 'solve', ......)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by