How to optimise 2 variable with different dimension?

1 view (last 30 days)
I have two motion data set. The first data set is x, the system state which contains all the joint angles of a 2D arm in different time frame and the last data set is u, 1d control input in different time frame. I have to do a motion optimisation where i have to find the optimised x and u by minimising a objective function. I have tried using matlab function like fminunc, fminsearch and lsqnonlin. However i have no idea how to set two different variables data set with different dimension as an initial guess for the optimisation function.

Accepted Answer

Walter Roberson
Walter Roberson on 27 Nov 2012
The initial guess should be a single vector which is the vector concatenation of all of the entries to be varied. The optimization function you pass should break the vector into appropriate pieces.
For example, if x0 is (say) 5 x 2, and u0 is (say) 7 x 1, then
initial_guess = [x0(:); u0(:)];
and the minimization function would accept a single parameter,
function output = myminfunc(P)
thisx = reshape(P(1:10), 5, 2);
thisu = P(11:17);

More Answers (1)

Wei Cai Law
Wei Cai Law on 27 Nov 2012
Now i have to represent x (2 x n) and u (1 x n-m) using cubic B-splines and the solve the optimisation problem. I tried using the function csapi to convert them into spline form. However the optimisation function could not read the data type of the spline. I tried with fmincon and lsqnolin. Both gave the same error. Did i miss out something or the function i used is unsuitable?

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!