I have a complex problem to solve and I'm using the fmincon solver. Firstly I wrote the equality and inequality constraints like it was done in the user guide for Optimisation Toolbox in the following form:
variables = {'I1','I2','HE1','HE2','LE1','LE2','C','BF1',...'BF2','HPS','MPS','LPS','P1','P2','PP','EP'};N = length(variables);% create variables for indexing
for v = 1:Neval([variables{v},' = ', num2str(v),';']);end Aeq = zeros(4,16); beq = zeros(4,1);Aeq(1,[LE2,HE2,I2]) = [1,1,-1];Aeq(2,[LE1,LE2,BF2,LPS]) = [1,1,1,-1];Aeq(3,[I1,I2,BF1,HPS]) = [1,1,1,-1];Aeq(4,[C,MPS,LPS,HPS]) = [1,1,1,-1];
etc.
My question is how to assign these variables in separate script file to be able to write the nonlinear constraints in the form like this:
LE1^2+BF1^2=C*MPS : For example
Thank you.
Best Answer