(x-x0).^2+(y-y0).^2

x(100) and y(100) are two variables which are coordinates of moving object A. x0 and y0 are two constants which are coordinates of static object B. How can i write the distance between A and B?
(x-x0).^2+(y-y0).^2
Is this expression right?

This is confusing because of the 100. Do you have 100 sets of points?

Anyhow, use the two-norm. For instance (ignoring the 100, i.e., assuming x, y, x0, and y0 are all scalars), norm([x y]-[x0 y0])

If x, y, x0, and y0 are all 100 by 1, then
norms([x y]-[x0 y0],[],2)
produces a 100 by 1 vector of the 100 distances.

If x, y are 100 by 1, and x0 and y0 are scalars, then
norms([x y]-repmat([x0 y0],100,1),[],2)
produces a 100 by 1 vector of the 100 distances.

thank you Mark! I mean x,y are two vectors, and both of them are 100 by 1. so I think norms([x y]-repmat([x0 y0],100,1),[],2) might solve my problem.

I checked and norms([x y]-repmat([x0 y0],100,1),[],2 is the right form of the distance vector between two points. So can I use norms([x y]-repmat([x0 y0],100,1),[],2).^2 to express the square of the distance between two points?

In CVX 2.1, you need to use square_pos. You can use ^2 as you have proposed, in CVX 3.0 beta, but I don’t recommend use of CVX 3.0beta due to numerous bugs.