How to express rest of expression in terms of other variables

조회 수: 4 (최근 30일)
Hemanth
Hemanth 2024년 11월 29일
편집: Star Strider 2024년 11월 29일
Hi,
In the following code, I would like to get the final expression for p/Phi_V. How can I do that?
syms p K_B Phi_V Phi_G s K_i K_p real;
Phi_G = p/s*(K_p + K_i/s);
p = K_B*(Phi_V - Phi_G)

채택된 답변

Star Strider
Star Strider 2024년 11월 29일
편집: Star Strider 2024년 11월 29일
Try this —
syms p K_B Phi_V Phi_G s K_i K_p real;
Phi_G = p/s*(K_p + K_i/s)
Eqn1 = p == K_B*(Phi_V - Phi_G)
Eqn2 = isolate(Eqn1, p)
pretty(Eqn2) % Necessary To Display Reesult
2 K_B Phi_V s p == ------------------------ 2 s + K_B K_p s + K_B K_i
Eqn3 = Eqn2 / Phi_V
pretty(Eqn3) % Necessary To Display Reesult
2 p K_B s ----- == ------------------------ Phi_V 2 s + K_B K_p s + K_B K_i
EDIT — Added pretty calls. Corrected typographical errors.
.
  댓글 수: 2
Hemanth
Hemanth 2024년 11월 29일
Thank you so much!! you saved my day....
Star Strider
Star Strider 2024년 11월 29일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
If you add:
p_over_Phi_v = matlabFunction(rhs(Eqn3))
you can get an anonymous function for the expression
p_over_Phi_V = function_handle with value:
@(K_B,K_i,K_p,s)(K_B.*s.^2)./(s.^2+K_B.*K_i+K_B.*K_p.*s)
or more simply:
p_over_Phi_V = @(K_B,K_i,K_p,s)(K_B.*s.^2)./(s.^2+K_B.*K_i+K_B.*K_p.*s);
.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by