Unrecognized function or variable error code help required

조회 수: 7 (최근 30일)
Karim Wahdan
Karim Wahdan 2021년 1월 22일
댓글: Jan 2021년 1월 23일
I have created code on low rank assumption using nuclear norm using CVX. I am getting the following error code -
Unrecognized function or variable 'A_i'.
Error in Untitled3 (line 21)
y(i_m) == trace(A_i)*Xe;
here is my code any help will be appricated
r = 2; % the rank;
n = 4; % the dimension
a = randn(n,r);
b = randn(n,r);
X = a*b'; % low rank Matrix;
m=fix(n^2-1);
A = randn(n, n);
y = trace(A*X);
% low rank approximation using nuclear norm
cvx_begin
variable Xe(n,m)
minimize norm_nuc(Xe)
subject to
A*Xe == y
cvx_end
for i_m = 1 : m
y(i_m) == trace(A_i*Xe);
end
error = norm(X-Xe)
for m = 1 : 10 : n^2
for mc = 1 : MONTE_CARLO
% Generate measurements
y = zeros(m, 1);
for i_m = 1 : m
A_i = randn(n, n);
y(i_m) = trace(A_i*X);
end
% Solve problem
% Store results
end
end

답변 (1개)

Tayyab Khalil
Tayyab Khalil 2021년 1월 22일
This is because A_i is undefined in the code but is being used. What value do you want it to have?
  댓글 수: 8
Karim Wahdan
Karim Wahdan 2021년 1월 22일
@Jan Ok I want A_i to be the value 10. How would I put this into my code and fix my "matrix needs to be squared" error
Jan
Jan 2021년 1월 23일
Of course you should do this by:
A_i = 10;
Please post the complete error message and the corresponding code. I cannot guess where this error occurs.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by