# The input matrix must be a double-precision matrix or a logical matrix

Hi, everyone.I have problem to solve the following question, which is convex.
And this is my code

cvx begin
variable v_hat(T,d,K) complex
variable x_hat(d,d,K,K) complex
expression obj(1)
expression pt(1)
expression ob(K)

``````    for k = 1:K
ob(k) = ob(k) + square_pos(norm(sqrtm(W(:,:,k))*x_hat(:,:,k,k),'fro'));
ob(k) = ob(k) - trace(W(:,:,k)*x_hat(:,:,k,k)');
ob(k) = ob(k) - trace(W(:,:,k)*x_hat(:,:,k,k));
ob(k) = ob(k) + square_pos(norm(sqrtm(W(:,:,k)), 'fro'));
ob(k) = ob(k) + sigma^2 * square_pos(norm(sqrtm(W(:,:,k))*U(:,:,k),'fro'));
for m = 1:K
if m ~= k
ob(k) = ob(k) + square_pos(norm(sqrtm(W(:,:,k))*x_hat(:,:,k,m),'fro'));
end
end
obj = obj + weights(k) * ob(k);
end

for k=1:K
pt = pt + square_pos(norm(v_hat(:,:,k), 'fro'));
end

minimize (obj)

subject to
pt - PK <= 0;
for k=1:K
ob(k) <= r(k);
end
for k = 1:K
for m = 1:K
x_hat(:,:,k,m) - U(:,:,k)'*H(:,:,k)*v_hat(:,:,m) == 0;
end
end
cvx end
V = v_hat;
``````

When I ran my program, the error occurred at the beginning of the cvx:
Error Usage Sparse
The input matrix must be a double-precision matrix or a logical matrix.

Could you help me to handle this problem?
Thanks a lot.

Please clarify exactly when the error message appeared. Was it only after `cvx_end`? It should not have occurred prior to `cvx_begin`.

I don’t know whether this is a CVX bug, a version incompatibility, a corrupted MATLAB session, or maybe due to some “bad” input data in CVX expressions.

Easiest to try: Try specifying a different solver. Run in a new MATLAB session. If not successful, reinstall CVX, and make sure it is CVX 2.2 (not CVX 3.0beta).

If still not successful, try to show all input data for a minimum (as small and simple as possible to illustrate the error) reproducible example.

Thanks for your reply. The error occurred at the beginning of the CVX code, i.e., line: cvx begin
I run other CVX code and it works, thus it may have nothing to do with the version of the CVX.
Besides, the error message has mentioned the sparse function, so i think it maybe due to the ill condition of the matrix.

Try all off these steps I mentioned previously.

Easiest to try: Try specifying a different solver. Run in a new MATLAB session. If not successful, reinstall CVX, and make sure it is CVX 2.2 (not CVX 3.0beta).

Repeat: Do not use CvX 3.0beta. it works correctly on some problems. On other problems, it produces a wrong solution or an error message.

Yes, the version of the CVX is 2.2. And i reinstalled the CVX 2.2 (http://cvxr.com/cvx/download/ Windows mexw64 cvx-w64.zip) just now, it worked well on the test code, but the error still occurred on this code.

Thanks for your help. I have found out the reason. I made a rather stupid mistake.
I wrote cvx_begin and cvx_end as cvx begin and cvx end.
I recently started to learn the CVX so that i made such a stupid mistake.
Anyway, thanks for your help again.

I should have noticed that.