How can I define a symbolic function with vector arguments?
4 views (last 30 days)
Star Strider on 13 Jan 2022
A vector has only one dimension (that I am aware of), so I assume ‘x’ needs to be a (3x1) vector.
syms x % Declare 'x'
x = sym('x',[3,1]) % Create 'x' As A (3x1) Vector
f(x) = x(1)^2+x(2)^3+x(1)*sin(x(3))
Is this the desired result?
Walter Roberson on 20 Jan 2022
You cannot do that in MATLAB.
You can use matlabFunction with the 'vars' option to generate a function handle that indexes into a vector argument. This will not, however, be a symbolic function.
The technology used for symbolic functions at the MATLAB level does not allow vector arguments to be created and indexed.
The internal symbolic engine does have indexing ability, and it is possible to create a function at the engine level. However, the MATLAB level cannot handle those objects...