MATLAB: How do you create multiple symbolic variables

symbolicSymbolic Math Toolboxvariable

Here is my code, but is there a simpler solution?
% create symbolic variables x1,...,xn
for i=1:n
eval(join(['syms x' string(i)],''));
end

Best Answer

n = 4;
X=sym('x',[1,n]);
syms(X)
If you're using 2019a or later:
n = 4;
syms x [1 n]
Related Question