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.

Answers (1)

Pravarthana P
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);
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.

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

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

Start Hunting!