Multivariate symbolic math function from input sym vector
Version 1.0.1 (2.82 KB) by
Imran Khan
Outputs multidimensional and multivariate symbolic function from input symbolic vector
Currently, MATLAB's symbolic toolbox does not allow functions to be defined in the following way:
N = 3;
syms my_var [N 1];
syms my_func(my_var);
At present, doing this deletes the my_var variable and overwrites it as a scalar. The only way to define multivariate functions is explicitly, which requires knowing the input vector dimensionality beforehand:
syms my_func(my_var1,my_var2,my_var3);
my_var = [my_var1;my_var2;my_var3];
This function allows my_func to be defined through its input vector my_var:
N = 3;
syms my_var [N 1];
makeMultivariateSymFunctionFromInputVector(my_var,"my_func");
------
It also allows creation of multidimensional symbolic functions by just specifying the function_dimension, e.g. instead of:
syms my_func1(my_var1,my_var2,my_var3);
syms my_func2(my_var1,my_var2,my_var3);
syms my_func3(my_var1,my_var2,my_var3);
syms my_func4(my_var1,my_var2,my_var3);
syms my_func5(my_var1,my_var2,my_var3);
my_var = [my_var1;my_var2;my_var3];
my_func = [my_func1;my_func2;my_func3;my_func4;my_func5];
The function can be called:
N = 3;
syms my_var [N 1];
my_func = makeMultivariateSymFunctionFromInputVector(my_var,"my_func",5);
------
See the example m-file for more usage examples.
Cite As
Imran Khan (2025). Multivariate symbolic math function from input sym vector (https://in.mathworks.com/matlabcentral/fileexchange/167966-multivariate-symbolic-math-function-from-input-sym-vector), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Created with
R2022a
Compatible with any release
Platform Compatibility
Windows macOS LinuxTags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
