The error is occuring because the optim tool is trying to call test2() with a vector input, but you do not declare a vector input in the function's declaration. The interface to the objective function should look like
where x is a vector of your design variables.
Futhermore, the output of the objective function depends on your problem. What solver are you using? (It's an option specified in the optimtool GUI.) Can you describe your goal (objective function and constraints)in a bit more detail?
Best Answer