Simulink subsystem to numerically solve a complex exponential function

조회 수: 1 (최근 30일)
Ario
Ario 2021년 7월 30일
답변: Pavan Guntha 2021년 8월 30일
This is the Matlab script of what I have to solve at each iteration of a complex simulink model:
B, T and W known; solving for a:
sol = vpasolve( 0.88*(1-exp(-0.1*B))*(1-exp(-9.5*a)) - (0.9/B + 0.5*a/sqrt(B)) - T/W, a)
I cannot use this directley in a user defined Simulink funcation since symbolc variables are not accepted.
How would you suggest to draw/code this in Simulink?
Thanks!

답변 (1개)

Pavan Guntha
Pavan Guntha 2021년 8월 30일
Hello Ario,
You could follow the following steps to solve the issue:
1) Create a '.m' file containing the function (for example, name it complexExponential.m) to solve the complex exponential equation.
2) You could use a MATLAB Function block in Simulink to call this function as shown below.
coder.extrinsic('complexExponential');
out = 0;
out = double(complexExponential(inputs));
Since the equation involves symbolic variables, it is necessary to use 'coder.extrinsic()' to avoid generating code for it. For more details you could have a look at the documentation page of coder.extrinsic.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Schedule Model Components에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by