I have 's' domain terms in matlab function block, used in simulink. How to use it?
6 views (last 30 days)
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.
Pravarthana P on 28 Sep 2022
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);
and call this file from MATLAB function block as
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:
Create symbolic scalar variables and functions, and matrix variables and functions - MATLAB syms (mathworks.com)
How to use symbolic variables and functions (Syms) in a Simulink Matlab Function? - MATLAB Answers - MATLAB Central (mathworks.com)
I hope this information helps you.