# Are sum_square_abs and Vecnorm in matlab is same?

I have 2 Matrixes A and B both of size (n,2)
I want as in Matlab with using vecnorm(A-B,2,2), to get the norm of each row in a matrix (n*1)

for example
A = [ 1 2 ; 3 4]
B = [3 4 ; 2 1]
A - B = [-2 -2 ; -1 -3]
I want to get This:
ans =

``````2.8284
3.1623
``````

How can I represent this in CVX?
Thanks very much

`norms(A-B,2,2)`

help norms

norms Computation of multiple vector norms.
norms( X ) provides a means to compute the norms of multiple vectors
packed into a matrix or N-D array. This is useful for performing
max-of-norms or sum-of-norms calculations.

``````All of the vector norms, including the false "-inf" norm, supported
by NORM() have been implemented in the norms() command.
norms(X,P)           = sum(abs(X).^P).^(1/P)
norms(X)             = norms(X,2).
norms(X,inf)         = max(abs(X)).
norms(X,-inf)        = min(abs(X)).
If X is a vector, these computations are completely identical to
their NORM equivalents. If X is a matrix, a row vector is returned
of the norms of each column of X. If X is an N-D matrix, the norms
are computed along the first non-singleton dimension.

norms( X, [], DIM ) or norms( X, 2, DIM ) computes Euclidean norms
along the dimension DIM. norms( X, P, DIM ) computes its norms
along the dimension DIM.

Disciplined convex programming information:
norms is convex, except when P<1, so an error will result if these
non-convex "norms" are used within CVX expressions. norms is
nonmonotonic, so its input must be affine.``````
1 Like

Very Thanks    excuse me, another question:
are these statements the same in CVX?
` isequal(R >= eta , ones (K,1));`
and
` R >= eta`

I don’t understand your question. `isequal` can’t be applied to CVX variables or expressions. If you want to know whether two constraitnts are equivalent, show the variable declarations and state the two constraints.