# How to track the values of a variable which is changing in each iteration

I am using CVX to solve underdetermined system. The code used is

cvx_begin
variable x(n) complex;
minimize(norm(x,1));
subject to
A*x == y;
cvx_end

Is it possible to record that what initial value has been chosen for x and the progress in values of x in each iteration.

–Thanks

The only way I know to do this is to set the maximum number of iterations progressively higher and keep re-running CVX until the number of iterations is high enough to allow normal termination. After each CVX run, examine the CVX variable values. Even still, this will not produce the “initial” value.

For instance, if using sedumi, use the command
`cvx_solver_settings('maxiter',2)`
to set the maximum number of iterations to 2.

Use
`cvx_solver_settings('maxit',2)`
for sdpt3

Perhaps someone else has a better idea.

Actually I want to note ||x|| or residual history ||y-A*x|| after each step of progress(iteration) towards final solution, since only final values of these are available at display. For that may be variables to be displayed has to be changed but I am unable to get how to do this?

The approach I suggested above would allow this to be done, even though it is a kluge, and requires repetitious problem solving.

First solve the original problem and record the number of iterations, say M. Then re-run CVX limiting the maximum number of iterations the solver is allowed.

``````for i = 1:M-1
cvx_begin
variable x(n) complex;
minimize(norm(x,1));
subject to
A*x == y;
cvx_solver_settings('maxiter',i) % or cvx_solver_settings('maxit',i) or whatever is needed for your solver
cvx_end
disp([i norm(x,1) norm(y-A*x)]) % and/or save into an array, or whatever you want
end``````
1 Like

Thank you very much sir!! It served the purpose what I was looking for 