# Why this code the given error?

2 views (last 30 days)
Sadiq Akbar on 8 Sep 2021
Commented: Sadiq Akbar on 13 Sep 2021
close all; clear all; clc;
vec = @(MAT) MAT(:);
vecH = @(MAT) MAT(:).';
% M = 5;
M = 10;
N = 4;
% N = 10;
d = 0.5;
K = 3;
SNR_dB = 20;
steerVecT = @(ang) exp(1j*2*pi*d*[0:M-1].'*sin(vecH(ang)));
steerVecR = @(ang) exp(1j*2*pi*d*[0:N-1].'*sin(vecH(ang)));
angleGrid = [-80:1e-2:80].';
rng(222);
targetAngle = [-30, 0, 40].'+rand(K, 1);
A = ones(K, 1);
r = steerM*A;
noiseVar = r' * r / length(r) / db2pow(SNR_dB);
w = sqrt(noiseVar / 2) * (randn(size(r)) + 1j * randn(size(r)));
y = r+w;
lambda = 2*sqrt(M*N*log(M*N))*sqrt(noiseVar);
cvx_begin sdp quiet
variable x(N*M,1) complex
variable F(M*N,M*N) hermitian
minimize(norm(y-x))
subject to
[F, x; x', lambda^2]>=0
for idxN1 = 0 : 1 : N-1
for idxN2 = 0 : 1 : N-1
Ftmp = F(idxN1*M+1:idxN1*M+M, idxN2*M+1:idxN2*M+M);
for delta = -(M-1) : 1 : M-1
if ((idxN1==idxN2) && (delta==0))
sum(diag(Ftmp, delta)) <= 1/N;
else
sum(diag(Ftmp, delta)) == 0;
end
end
end
end
cvx_end
spectrumANM = abs(x'*steerGrid).^2;
spectrumANM = spectrumANM/max(spectrumANM);
figure; plot(angleGrid, spectrumANM);
% User defined function
function steerM = steerMatTR(targetAngle, steerVecT, steerVecR)
steerA = steerVecT(targetAngle);
steerB = steerVecR(targetAngle);
steerM = zeros(size(steerA, 1)*size(steerB, 1), length(targetAngle));
for idxK = 1 : 1 : length(targetAngle)
steerM(:, idxK) = kron(steerB(:, idxK), steerA(:, idxK));
end
After running the above code, it gives the following error:
Undefined function 'cvx_begin' for input arguments of type 'char'.
Error in main (line 32)
cvx_begin sdp quiet
Can anyone help me in this regard?
Sadiq Akbar on 8 Sep 2021
Thanks for the responses of both of you dear DGM and Adam Danz. No, I don't know anything about CVX? what is that and how to install that?

the cyclist on 8 Sep 2021
CVX is a third-party MATLAB toolbox (i.e. not from MathWorks), that you need to install according to their instructions. You need to go to their website to do that.
Sadiq Akbar on 13 Sep 2021
Thank you very much dear the cyclist for your guidance. Ok I am going to accept that. But actually I am thankful to all of you as I have mentioned earlier.