0

When I setup a Vector with 4 symbolic variables, it is ok. But an error happens for 5 variable, the detail is posted at below. Is the symbolic variable limited below 5?

My code for 5 variables: 

const Variable x0{"x0"};
const Variable x1{"x1"};
const Variable x2{"x2"};
const Variable x3{"x3"};
const Variable x4{"x4"};
  
Eigen::Matrix<Variable, 5, 1> x(x0,x1,x2,x3,x4);

Results: 
error: no matching constructor for initialization of 'Eigen::Matrix<Variable, 5, 1>'
Eigen::Matrix<Variable, 5, 1> x(x0,x1,x2,x3,x4);
Wc Chang
  • 97
  • 6

1 Answers1

1

This has nothing to do with symbolic variable, the problem is that Eigen doesn't provide a constructor for a vector with 5 entries. You cannot do Eigen::Matrix<double, 5, 1> x(1, 2, 3, 4, 5) either

You could do

Eigen::Matrix<symbolic::Variable, 5, 1> x;
x << x0, x1, x2, x3, x4;
Hongkai Dai
  • 2,546
  • 11
  • 12