Variable definition

Dears
I want to do minimization in CVX, but I got error
minimize norm y-sum(Aixiz) with given x
it means I want to find A but because of practical material I need to calculate " i rows of matrix A " and then do multiplication in i th row of vector x and do it again.

A is a matrix 10025 (unknown)
y is a vector 25
1(known)
x is a vector 251(known)
z is a vector 25
1(known)
so as I said I derive A1 by 25 rows of matrix A and then calculate A1xiz and do it four times and then adding them to find sum(Aixiz) at final I want to minimize norm (y- sum(Aixiz) )
I do not know how to implant this in CVX because if I says my variable is A how can I implement it in minimization part ?
I hope this help to know what am I saying and Thanks for help
regard

Can you write out your problem more clearly? Any mathematical operations, such as matrix and vector multiplication, which you want to do in CVX, have to make sense if all the variables were MATLAB variables and CVX were not involved at all. In particular, matrix and vector multiplications need to be “conformal”, i.e., have properly matching dimensions.

So xi * z does not even make sense because a 25 by 1 vector can not be multiplied by a 25 by 1 vector. I can’t tell you how to fix this, because I don’t know what you are trying to do.

xi is the i th element of vector x.

minimize

Pretend that you are not using CVX, and that everything is a MATLAB variable with already provided numerical value. How would you calculate the numerical value of your objective function? Once you figure that out,it should be easy to convert that into CVX code. Although it’s usually a good idea to vectorize your code where possible, CVX allows you to use for loops to build up expressions.


is it correct to do like that?
variable p(5,1)
for i=1:5
obj=obj+p(i)*p(i)
end
minimize (obj)

That is valid provided that you have the statement obj = 0 before the for loop.

However, this can be written in a vectorized way as follows:

variable p(5,1)
minimize(sum(p.^2))

1 Like