Info

此问题已关闭。 请重新打开它进行编辑或回答。

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

1 次查看(过去 30 天)
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