First part:
x0 = [x0;x0;x0;x0;x0];
options = optimset('Display','iter');
zvals = 0 : 2 : 50;
numz = length(zvals);
x = zeros(5, numz);
fvals = zeros(1,numz);
for K = 1 : numz
z = zvals(K);
[x(:,K),fvals(K)] = fsolve(@(x) Man(x,z), x0, options)
end
Second part:
x0 = [x0;x0;x0;x0;x0];
zvals = 0 : 2 : 50;
numz = length(zvals);
x = zeros(5, numz);
fvals = zeros(1,numz);
for K = 1 : numz
z = zvals(K);
[x(:,K),fval(K)] = fmincon(@(x) F(x,z), x0, [], [], [], [], zeros(5,1), 2*pi*ones(5,1));
end
plot(zvals, fval)
Best Answer