Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Lynn
Lynn el 8 de Abr. de 2014
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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!

Respuestas (1)

Walter Roberson
Walter Roberson el 8 de Abr. de 2014
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 comentarios
Lynn
Lynn el 8 de Abr. de 2014
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 el 8 de Abr. de 2014
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', ......)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by