Prox is not working. X(:, i+1) is not well defined. When I put X = rand(10,1) and prox_L1(X, 0.5) then it's working. But I am not getting X(:, i+1). I want to run the followin

5 views (last 30 days)
n = 10;
p=1;
A= rand(n);
A= 0.5*(A'+ A);
i=1;
X(:,i)=rand(n,p);
lambd3(i) = 1/3;
mu = 0.9;
for i = 1:100
a_i = 1/(i+1)^0.5;
L=(norm(A))^2;
beta= abs(min(eig(A)));
s_i=2*beta/L;
gamma_i = 0.005*s_i;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
%%Alg1
f_i = -2*X(:,i)'*A'*A;
%2*A'*A*X(:,:,i) - 2*A'*B;
Z_i = X(:,i) - s_i*(f_i);
Y_i = prox_L1(Z_i,gamma_i);
X(:,i+1) = Y_i;
L(i) = norm(X(:,i+1) - X(:,i))
% n(i)=i;
end
n=[1:1:100];
plot(n,L(n),'color',[0.80 0 0], Marker='-.','LineWidth',2,'markersize',4);
  1 Comment
feeroz babu
feeroz babu on 25 Jan 2022
> n=10;
>> p=1;
>> X=rand(n,p);
>> prox_L1(X, 0.5)
ans =
0.386084092595876
0
0.150081811040748
0
0.330508755645148
0
0.495992461466452
0
0
0
>>

Sign in to comment.

Accepted Answer

Sriram Tadavarty
Sriram Tadavarty on 8 Jun 2023
Hi Feeroz,
Here are some of the inputs that I can provide without knowing how the prox_L1 code is.
The issue is that Z_i is a matrix of size 10 x 10, and this matrix is trying to fit to a vector X of size 10 x 1.
When the value of X(:,i) set to rand(n,p) gives a column vector of length 10, since p is 1. The matrix A is of size 10 x 10.
f_i = -2*X(:,i)'*A'*A; % Here f_i is of size 1 x 10
Z_i = X(:,i) - s_i*(f_i); % Here Z_i is of size 10 x 10
% This Z_i is passed to prox_L1 function, which might return the output
% with same dimensions thereby not able map to a vector of length 10.
When Z_i is of size 10 x 1, then the code would run as expected. So, updating f_i or Z_i could be a solution to avoid the issue.
Another aspect is to define X with zeros before accessing the elements, as it would make the code clear. Like, in this case X can be initialized to zeros(10,101). first input 10 is for n, second input 101 is to access all the i & i+1 values in the for loop.
Hope this helps.
Regards,
Sriram

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!