Hi , I am trying to do a linprog optimisation by referring to the example in Matlab. I need help to solve the errors. Ty.
my code is:
variables = {'e1','e2','p1','p2','a','c','k','m','y','z'};N = length(variables); % create variables for indexing
for v = 1:N eval([variables{v},' = ', num2str(v),';']); end% Lower Bound Constraints
lb = zeros(size(variables));lb([e1,e2,p1,p2]) = [14.4,14.4,26.4,28.8];% Upper Bound Constraints
ub = Inf(size(variables));ub([e1,e2,p1,p2,k,m]) = [48,48,84,84,2.5,2.5];% Other Constraints
A = zeros(2,4);A(1,k) = 1; A(1,e2) = -1/36; b(1) = 1.7;A(2,m) = -1; A(2,p2) = -1/36; b(2) = 1.7;Aeq = zeros(2,4); beq = zeros(2,1);Aeq(1,[a,e1]) = [1,-7/30];Aeq(2,[c,p1]) = [1,-7/60];% Objective function
if a <= c y = a;else y = c;endif k <= m z = k;else z = m;endf = z*y*24768;% Solve the Problem with linprog
[x, fval] = linprog(f,A,b,Aeq,beq,lb,ub);for d = 1:Nfprintf('%12.2f \t%s\n',x(d),variables{d})endfval;
Best Answer