# Least mean square optimimization with a constraint

I have a piece of code in Matlab(given in the end of this post).

I am trying to find a least mean square solution for w with the equation A*w = AntPattern’ with the constraint that the elements of w should be of unit magnitude.ie |w(i)| = 1 for all i.

How can I impose this constraint on cvx.

How can I rewrite the following portion

cvx_begin quiet
variable w(m) complex
minimize(norm(A*w - AntPattern’))
subject to
norm(w.*w) = 16;
cvx_end

to satisfy the problem and constraint.

The following error is coming while executing the matlab code.

Error using .* (line 262)
Disciplined convex programming error:
Invalid quadratic form(s): not a square.
Error in ant_array_min_beamwidth_learn (line 63)
norm(w.*w) = 16;

%Start of matlab code
AntPattern = [0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 1 1 1 1 1 1 1 1 1 1 1 0.702174976 0.571028977 0.493164683 0.44019878 0.401211731 0.370990763 0.346692132 0.326615658 0.309674343 0.295136587 0.28248956 0.271361717 0.26147641 0.25262285 0.244637234 0.237390091 0.230777553 0.224715195 0.219133599 0.213975085 0.209191283 0.204741284 0.200590227 0.196708195 0.19306935 0.189651245 0.186434274 0.183401229 0.180536932 0.177827941 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777 0.031622777];

``````thetaDeg = -90:90;

c = 3e8;
f = 3.3e9;

lambda = c/f;

N = 16;

dy = 0.4*lambda;
n = 1:N;
yn = (n - 0.5*(N+1))*dy;

A = exp(2*pi*1j/lambda*sin(theta')*yn);

m = 16;

cvx_begin quiet
variable w(m) complex
minimize(norm(A*w - AntPattern'))
subject to
norm(w.*w) = 16;
cvx_end
``````

%End of matlab code

norm(w.*w) = 16;

looks nonconvex to me. Is that a convex set`?