How to use symbolic variables and functions (Syms) in a Simulink Matlab Function?

I would like to create a Symbolic function within a Simulink Matlab Function to solve the variables h and t1. Matlab produces error “The function ‘syms’ is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.” when I try to compile the Simulink Matlab function with the following code.

syms Eq1(h,t1);
Eq1(h,t1) = h*t1;

I tried adding “coder.extrinsic(‘syms’)” at the top, as shown below, and this generated the error “Undefined function or variable ‘h’.”

syms Eq1(h,t1);
Eq1(h,t1) = h*t1;

How do I use symbolic variables and functions (Syms) in a Simulink Matlab Function?

ANSWER provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

I think the only solution is to use the syms function inside a separate .m file and call that file as extrinsic.

Create a new .m file, e.g. solveSyms.m, put all your code there:

function out = solveSyms(in)  % add necessary inputs and outputs
syms x y
f = x^2*y + 5*x*sqrt(y);
out = subs(f, x, in);

Now call this new file from the MATLAB Function block:

out = 0;
out = solveSyms(in);

I’m not very familiar with Symbolic Math toolbox, so you would need to correct the code above to use your equation.




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.