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)'});
引用格式
Siamak (2024). sym2fun (https://www.mathworks.com/matlabcentral/fileexchange/65186-sym2fun), MATLAB Central File Exchange. 检索来源 .
MATLAB 版本兼容性
平台兼容性
Windows macOS Linux类别
- Mathematics and Optimization > Symbolic Math Toolbox > Mathematics > Formula Manipulation and Simplification >
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!版本 | 已发布 | 发行说明 | |
---|---|---|---|
1.0.0.0 |