Why 'solve' function does not work with me

조회 수: 3 (최근 30일)
Esraa Abdelkhaleq
Esraa Abdelkhaleq 2016년 5월 17일
편집: Walter Roberson 2016년 5월 18일
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
FannoFlow
FannoFlow 2016년 5월 17일
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 2016년 5월 17일
Yes, changing from function to variable is the way to proceed. MrCov, you should repost as an Answer

댓글을 달려면 로그인하십시오.

채택된 답변

FannoFlow
FannoFlow 2016년 5월 17일
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
Esraa Abdelkhaleq
Esraa Abdelkhaleq 2016년 5월 18일
편집: Walter Roberson 2016년 5월 18일
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))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by