How to use looping in CVX tool

(Sunny) #1

I want to run my CVX problem many times so that I can get its average value, however CVX just give me the opt value once, how to do that?

(Mark L. Stone) #2
cvx_optval_array = NaN(10,1);
for joeblow = 1:10:
  cvx_optval_array(joeblow) = cvx_optval

You can similarly save optimal cvx variable values if you desire.

(Sunny) #3

Thanks but it is showing me same value at each loop.

for i = 1:10;


while using this, I am able to obtain different opt_val, where solution1 is my CVX problem. but the problem in this is that i cant save all values, because of the same name of opt_val.
Any suggestion?

(Mark L. Stone) #4

I just showed you how to save the result from each time through the loop into an array. if that doesn’t answer your question, I don;t understand your question.