필터 지우기
필터 지우기

How can i get a symbolic equation to a matlabFunction handle without the RootOf Problem

조회 수: 2 (최근 30일)
I have created a symbolic equation out of state space. Now I want to get the equation out of the function by function handle. I tried to get it with matlabFunction to a function handle, but i get the failure RootOf in the Command Window. What could be the problem. For the Function Gjw in Frequeny area there is no problem. The Failure comes only at hEq.ht in time area.
Gs = simplify(C*(s*eye(size(A)) - A)^(-1)*B + D);
Gjw = subs(Gs,s,1i*w);
Hs = Gs*1/s*Amp;
ht = ilaplace(Hs);
hEq.Gjw = matlabFunction(Gjw,'vars',{w,Ta,J,K1,K2,VP,KCDC,Ch,Ak,Kp,Amp,flagmV});
hEq.ht = matlabFunction(ht,'vars',{t,Ta,J,K1,K2,VP,KCDC,Ch,Ak,Kp,Amp,flagmV});
Could you imagine what could be the failure?
  댓글 수: 6
Thomas Kraus
Thomas Kraus 2022년 3월 30일
I don't know where the z is come from. It is not from my function description. It is included as soon as I use vpa(ht).

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

답변 (1개)

Ishu
Ishu 2024년 2월 5일
Hi Thomas,
If you check your "ht" value then it contains the expression of root. As "matlabFunction" is not able to resolve symbolic expressions containing root expressions that's why you are getting "RootOf" error while calculating "hEq.ht". So firstly you have to resolve these root expressions by simplifying expressions only then you can apply "matlabFunction" to solve further. To simplify these expressions you can try below methods:
  1. Try simplifying the expression using "simplify" function.
  2. As the expression contains roots so you can try to solve this expression explicitly using "solve" function.
  3. If the roots cannot be represented explicitly, you might consider using a numeric approximation for the roots using "vpasolve" function. This approach, however, will limit the usage of the function handle to numeric inputs only.
  4. If the expreesion contains variables that you want to replace only with specific values then to make it more simpler you can use "subs" function to substitute the values and then try to use "matlabFunction".
Below are some MathWorks documentations that you can refer:

카테고리

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

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by