I have 's' domain terms in matlab function block, used in simulink. How to use it?

5 次查看(过去 30 天)
I am doing as simulation in matlab simulink. There i am using a matlab function block which contains "s" domain terms (i want to change it to Z domain ) but it is showing error " The function 'syms' is not supported for standalone code generation". The out of that function should be a signal.

回答(1 个)

Pravarthana P
Pravarthana P 2022-9-28
Hi Shubham Mandve,
I understand that you are facing an issue while using MATLAB function block in Simulink. It can be due to using the symbolic variables or functions inside the MATLAB function block. A possible workaround can be:
To place the symbolic declarations and operations in a separate .m file and call that function from MATLAB function block as an extrinsic function.
For example, create a new .m file as,
function output = Syms_in_simulink(in)
syms x y
f = x*y+x*y^2;
output = subs(f,x,in);
output = double(output);
end
and call this file from MATLAB function block as
coder.extrinsic('Syms_in_simulink');
out = Syms_in_simulink(in);
For more information about extrinsic functions this documentation link can be helpful.
This workaround will likely work when ‘acceleration’ or ‘normal’ mode is used during code generation, because the ‘rapid acceleration’ mode during the code generation backing MATLAB execution engine is limited which is required to execute anything inside the symbolic toolbox.
The following documentation links can be helpful to understand the same further:
I hope this information helps you.

类别

Help CenterFile Exchange 中查找有关 Simulink Coder 的更多信息

产品


版本

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by