title: For loop in using fmincon function for different initial points
body: <p>I know this question is really too basic, but I am stuck since I am new to MATLAB. The problem is I do not know how to use <strong>for-loop</strong> to show three output of V in one run for different initial points. </p>
  
  <p>I would like to have an output like the following:</p>
  
  <p>V1 (first initial point)-----V2(second initial point)-----V3(third initial point)</p>
  
  <p>This is my code:</p>
  
  <pre><code>%variables
  ENG1=0.52;
  ENG2 = [0.00139;0.00149;0.00122;0.00130;0.000866;0.000731;0.001002;0.001285];
  ENG3 = zeros(8,1);
  %6.2.2) minimization term
  fun = @(V) abs(ENG1 - V'*ENG2);
  %6.2.3) constrains:
  Aeq = [ENG3';ones(1,8)];
  beq = [0;1]; 
  lb = zeros(8,1); %lower bound
  ub = ones(8,1); %upper bound
  V0 = rand(8,1);V0 = V0/sum(V0); %initial guess
  options = optimset('Display', 'off'); %supressing extra unnecessary outputs.
  for i=1:3
      V(i) = fmincon(fun,V0,[],[],Aeq,beq,lb,ub,[],options)
  end
  </code></pre>