Empty plot: I need to plot one variable vs Results of fmincon

clc
d0 = 0.01:1;
Xmat = zeros(numel(d0),5);
for i=1:numel(d0)
d0_actual = Ef(i);
x0 = [0.08, 9.14, 10, 1, 0.1];
options=optimset('fmincon');
options.Display='iter';
options.Algorithm='interior-point';
fitnessfcn = @(x)Lobo(d0_actual, x(2), x(3), x(4), x(5));
nonlcon1 = @(x)nonlcon(d0_actual, x(2), x(3), x(4), x(5));
lb = [0.08, 9.14, 10, 1, 0.1];
ub = [1, 18.3, 1300, 25, 1];
[X, fval] = fmincon(fitnessfcn, x0, [], [], [], [], lb, ub, nonlcon1, options);
Xmat(i,:) = X(:);
X
disp(X);
end
plot(d0(i), Xmat(i,1));

8 Comments

Tried that. Still the same. It is only taking a single value.
That's no surprise ; d0 only has 0.01 as value (i.e. numel(d0)=1).
What I am trying here is to plot all the values of d0 vs all the values of Xmat. I defined a range of values using,
d0 = 0.01:1;
for each value of d0, I have a Xmat stored as,
Xmat(i,:) = X(:);
Then why is there no plot?
d0 = 0.01:1
generates d0 as d0 = 0.01, i.e. one single value, not a vector of values as you might expect.
Maybe you mean d0 = 0.01:0.01:1 ?
Best wishes
Torsten.
Oh But, when you don't want to provide a step size it's d0 = 0.01:1; Right ? Or is it? d0 = 0.01:1;
If you write d0=0.01:1, the step size is automatically chosen to be 1. Since 0.01+1 = 1.01 > 1, lower limit + stepsize > upper limit. Thus d0 = 0.01 only.
Best wishes
Torsten.

Answers (0)

This question is closed.

Tags

Asked:

on 4 Apr 2018

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!