sym2fun

Version 1.0.0.0 (3.87 KB) by Siamak
sym2fun converts symbolic expressions to anonymous functions using vector symbolic arguments.
78 Downloads
Updated 25 Nov 2017

View License

sym2fun converts symbolic expressions to anonymous functions based on vector representations of the symbolic arguments.
syntax
f = sym2fun(fsym, vars, symVec1, repVec1, ..., symVecN, repVecN)

Description
f = sym2fun( __ ) converts the symbolic statement fsym to an anonymous function handle f with the input arguments listed in vars. The input pairs symVec and repVec contain the symbolic vectors and the corresponding numerical vector representations. The data types for the input arguments are:
f: an anonymous function handle
fsym: an NxM symbolic matrix
vars: a cell array that contains the input names for f (that is f = f(vars{1}, vars{2}, ..., vars{p})
symVec: A vector of symbolic arguments
repVec: A cell array that contains the replacement names for each of the entries in symVec.

Example
>> x = sym('x%d',[3,1],'real');
>> y = sym('y%d',[3,1],'real');
>> p = [2*cos(x(1)) + 7*y(1)^2; sin(x(2)+y(2))];
>> J = jacobian(p,[x;y]) + randi([-10 10],2,4);
>> f = sym2fun(J, {'x','y'}, x, {'x(1)','x(2)'}, y, {'y(1)','y(2)'});

Cite As

Siamak (2024). sym2fun (https://www.mathworks.com/matlabcentral/fileexchange/65186-sym2fun), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Formula Manipulation and Simplification in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0.0