min ||A(x)-B|| over x and A is a linear mapping

# How to write the following in CVX?

**Mark_L_Stone**(Mark L. Stone) #2

`A(x)`

means `A*x`

for some input matrix A?

If so,

```
cvx_begin
variable x(size(A,2))
minimize(norm(A*x-B))
% insert any constraints
cvx_end
```

Have you read the CVX Users’ Guide http://cvxr.com/cvx/doc/? This is about as straightforward a problem as there is to enter into CVX.

**dazzy_L**(dazzy .L) #3

the mapping is a vector x to matrix mapping , that is confusing me , we can’t make it as a multiplication as u wrote , ofcourse i read the guide and had no clue how to solve it

**Mark_L_Stone**(Mark L. Stone) #4

What are the dimensions of `x`

and `B`

? Presumably, `A(x)`

has the same dimensions as `B`

.

If `x`

were a numerically-populated MATLAB (not CVX) variable, what MATLAB code would you use to evaluate `A(x)`

? If you can not answer that, I doubt anyone here can help you. So far, all we know is that `A(x)`

is a mysterious linear map from a vector to a matrix.

Is it something like `A`

being m by n matrix, `x`

being n by 1 vector, `B`

being m by p matrix, and `A(x) = repmat(A*x,1,p)`

? If so, use `minimize(norm(repmat(A*x,1,p)-B))`

Whatever it is, if it is a linear map,. and you know how to evaluate it in MATLAB,. you hopefully will be able to code it the same way in CVX when x id declared a CVX variable, as opposed to being a numerically-populated MATLAB variable,.

**dazzy_L**(dazzy .L) #5

sir i posted another question its an extension to this with more details , take a look at it , thanks in advance