# Why this code the given error?

2 views (last 30 days)

Show older comments

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].';

steerGrid = steerMatTR(deg2rad(angleGrid), steerVecT, steerVecR);

rng(222);

targetAngle = [-30, 0, 40].'+rand(K, 1);

A = ones(K, 1);

steerM = steerMatTR(deg2rad(targetAngle), steerVecT, steerVecR);

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?

### Accepted Answer

the cyclist
on 8 Sep 2021

### More Answers (0)

### See Also

### Community Treasure Hunt

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

Start Hunting!