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.
인용 양식
Imran Khan (2025). Multivariate symbolic math function from input sym vector (https://kr.mathworks.com/matlabcentral/fileexchange/167966-multivariate-symbolic-math-function-from-input-sym-vector), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2022a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!