;

    <span class="keyword">for</span> i = 1:M-1
      <span class="keyword">if</span>( mod(i,100) == 0 ), fprintf(1,<span class="string">'progress counter: %d\n'</span>,i), <span class="keyword">end</span>;
      y(i+1) + v(i)^pwj &lt;= y(i);
      w(i+1) + y(i)*v(i)^pwi &lt;= w(i);
    <span class="keyword">end</span>

    y(M) == v(M)^pwj;
    w(M) == y(M)*v(M)^pwi;
cvx_end

<span class="comment">% plot the basic optimal doping profile</span>
figure, clf
nbw = 0:1/M:1-1/M;
semilogy(nbw,v,<span class="st