how to take whole matrix using loop index

i have complex matrices for all hs, theta1 and W, in ist itration i have taken W with all one matrix, using all one W in prob#1 i have to find optimizte theta1(i) and then this theta1(i) is used in next prb#2 to get optimize W(i+1). my question is that this is itrative process and what should do to get a theta1 and W as matrices not an elements.

for i=1:1:100

%%prob#1

cvx_begin sdp

variable theta1(L+1,L+1) complex semidefinite

maximize(real(trace( theta1(i)HsW(i)*Hs’ )))

subject to

real(trace(theta1(i)HpkW(i)*Hpk’))<=gamma_k;

for t=1:L+1

real(theta1(t,t))<=1;

end

%theta1(i) == semidefinite(L+1);

cvx_end

%% prob#2

cvx_begin sdp

variable W(M,M) complex semidefinite

maximize(real(trace( theta1(i)HsW(i+1)*Hs’ )))

subject to

real(trace(theta1(i)HpkW(i+1)*Hpk’))<=gamma_k;

real(trace(W(i+1))<=P;

%W(i+1) == semidefinite(M);

cvx_end

%%etta is a factor =0.

etta(i+1)=trace(theta1(i)HsW(i+1)*Hs’);

tol_factor is also a scalar value

if real(etta(i+1,))-real(etta(i)<=tol_factor

break;

else

i=i+1;

end

If you are using CVX as part of a higher level iterative algorithm, it is your responsiility to determine whether that algorithm is useful for yuur intended purpose.

Spoiler alert: many iterative algorithms which call CVX don’t necessarily converge to anything, let alone to a global or even local optimum of whatever problem you are trying to solve.

if you have a specific syntax question, you need to make clear what the mathematical model you are trying to implement is. Readers will likely have no idea if you don’t tell them explicitly.

this is the algorithm I am implementing, I need suggestions about how to use Loop in case of w(I) to theta1(I) and then to w(I+1)

You haven;'t shown us (P3.1) or (P3.2).


Problem 3.1 and 3.2 have set of constraints I have also attached a separate Snapchat for those constraints as well, I am new to alternate optimization and how this itrative algorithm works.

Forget about any “iterative” algorithm for the moment. Do you know how to enter 12a-e for a single optimization problem? If you use CVX’s sdp mode, the CVX cide will look close to the equations as written.

Yes I have taken help from cvx-guide I think prom3.1and 3.2 is correctly implemented, my first step was to implement them separately.

Do you have any unresolved question?

Apart from that itration problem, i have no other question.

What specifically is your iteration question?

As you can see in alogrthem snapshot I have to ist slove the problem 3.1 to get a value of theta and use that theta value in problem 3.2 to find W, I know how to sdp and cvx, these values should b itratiivly changed for example I have theta(1) this 1 should not index the elements of matrix but it should be like the theta (whole matrix) this matrix after optimization used in problem 3.2 and we get a W(i+1) this W(i+1) again should be a matrix , so I am having issues how to use Loop to update these matrics. If I am using 2 loops one for row and one for colum all computing is done element vise , if am using linear indexing again computing is done element vise but I need a whole matrics every time and it should be updated accordingly.
I have W =all ones matrix of 6×6 for initiating, this W(i) is use to solve theta(i) and then theta(i) is use to slove W(i+1).

In MATLAB, a matrix can be set equal to some other matrix, by using a single assignment statement. That is used in thew code below.

You can fill out the details and fix up array dimensions, etc.

W_new = ones(n,n);
For i=1:100
%  CVX problem to solve P3.1 for theta:
cvx_begin
variable theta(n,n) semidefinite
% use W_new
...
cvx_end
theta_new = theta; % should really check to see optimal solution was found befoe doing this
% CVX problem to solve P3.2 for W
cvx_begin
variable W(n,n) semidefinite
% use theta_new
..
cvx_end
W_new = W; % should really check to see optimal solution was found before doing this
end

Thanks for you suggestions and time, I have got an idea but it still not working I am thinking of using loop for theta (all rows, all col, loop index).I is in shape of theta (:,:,i) doing this theta will be in 3d array. I will make use of abov suggestion. If you have any idea about above issue let me know.

You have to show exact code to allow diagnosis.