I am solving an optimization problem.There are no equality constraints in my model. I want to pass ODEs as constraint to fmincon using,non-linear constraint, nlcon argument .
The function model contains odes
function dz = model(t, z, c)
dz(1) = ..
dz(2) = ..
I'd like to ask how the ode intergrator has to be called in the place of nlcon in fmincon(@objective,p0,A,b,Aeq,beq,lb,ub,nlcon).
A = ;
b = ;
Aeq = ;
beq = ;
nlcon = ode45(@(t,z)model(t,z,x), tSpan, z0);
p = fmincon(@objective,p0,A,b,Aeq,beq,lb,ub,nlcon);
Since the ode function is already called in nlcon , is it required to call the function model again inside the objective function?
function cost = objective(c,time_exp,expZ,tSpan,z0)
sol = ode45(@(t,z)model(t,z,c), tSpan, z0);
ModelZ = deval(sol, time_exp);
cost = ModelZ-expZ;
Any help would be highly appreciated.