Why 'solve' function does not work with me

3 visualizaciones (últimos 30 días)
Esraa Abdelkhaleq
Esraa Abdelkhaleq el 17 de Mayo de 2016
Editada: Walter Roberson el 18 de Mayo de 2016
I want to solve this Eqn for qpl(s):
L(s) = qpl(0) - Kel*qpl(s) - s*qpl(s) + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s)
When I tried to solve it using "solve" function, an error appeared and I do not understand what is the mistake. I know that if I want to solve such equation I should type:
S = solve(eqn, var)
So I wrote:
syms Kel Nh0 Rh fplh Nc0 Rc fplc Kgr real
syms qpl(s) s
L(s) = qpl(0) - Kel*qpl(s) - s*qpl(s) + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s);
S = solve (L(s),qpl(s))
But error appeared. Any help?
  2 comentarios
FannoFlow
FannoFlow el 17 de Mayo de 2016
Was the error that it couldn't find an explicit solution? If so, thats because when it tried so solve, it simply couldn't find any way to solve for qpl(s).
Speaking of which, I'm not sure what you are trying to do with your notation, but if you are writing L(s) meaning that L is a function of s, try doing this instead:
syms Kel Nh0 Rh fplh Nc0 Rc fplc Kgr real
syms qpl_s s
L_s = qpl(0) - Kel*qpl_s - s*qpl_s + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s);
S = solve (L_s,qpl_s);
this gets me a solution of qpl_s as
S =
(qpl(0) + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s))/(Kel + s)
Walter Roberson
Walter Roberson el 17 de Mayo de 2016
Yes, changing from function to variable is the way to proceed. MrCov, you should repost as an Answer

Iniciar sesión para comentar.

Respuesta aceptada

FannoFlow
FannoFlow el 17 de Mayo de 2016
Was the error that it couldn't find an explicit solution? If so, thats because when it tried so solve, it simply couldn't find any way to solve for qpl(s).
Speaking of which, I'm not sure what you are trying to do with your notation, but if you are writing L(s) meaning that L is a function of s, try writing those variables as X_s instead, which declares them as variables in the workspace which Matlab can interpret and solve for.
syms Kel Nh0 Rh fplh Nc0 Rc fplc Kgr real
syms qpl_s s
L_s = qpl(0) - Kel*qpl_s - s*qpl_s + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s);
S = solve (L_s,qpl_s);
this gets me a solution of qpl_s as
S =
(qpl(0) + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s))/(Kel + s)
  1 comentario
Esraa Abdelkhaleq
Esraa Abdelkhaleq el 18 de Mayo de 2016
Editada: Walter Roberson el 18 de Mayo de 2016
Thanks a lot.
yes, the error is that it couldn't find an explicit solution. L(s) is the Laplace Transform of a previous equation.
The original equation is:
dq_PL(t)/dt= f_(PL,C)*R_C*N_(C,0)*e^(K_GR*t)+ f_(PL,H)*R_H*N_(H,0)- K_EL*q_PL(t)
Taking the Laplace Transform:
clear E
syms fplc Rc Nc0 Kgr fplh Rh Nh0 Kel real
syms qpl(t) s
dqpl(t)= -diff(qpl(t),t)+fplc*Rc*Nc0*exp(Kgr*t)+fplh*Rh*Nh0-Kel*qpl(t);
L(t) = laplace(dqpl(t));
L(s) = subs (L(t),{laplace(qpl(t), t, s)},{qpl(s)})
The solution is:
L(s) = qpl(0) - Kel*qpl(s) - s*qpl(s) + (Nh0*Rh*fplh)/s - (Nc0*Rc*fplc)/(Kgr - s)
Then, I want to solve it for qpl(s).
But the solution for qpl(s) must be:
q_PL (s)=(-f_(PL,H)*R_H*N_(H,0)*K_GR (K_GR*q_0 - f_(PL,H)*R_H*N_(H,0) -f_(PL,C)*R_C*N_(C,0))*s q_0*s^2)/(s(s-K_GR)(s+ K_EL))

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by