I read a piece of code in a SDP model,like this:

variable V(24,1)

expression W(14,14)

for in=1:14

W(in,in)=W(in,in)+sparse(tx,fx,V,14,14)

end

I tried let W as zeros and V as ones, it dosen’t work.But it works in a model this way.

Why?

What’s this mean?

Hope for your help.

Cheng Kung

Where tx and fx are 24*1 vectors

EDIT: Sorry, I misread. the `sparse`

function is placing the elements of `V`

in the locations enumerated by the rows `tx`

and the columns `fx`

.

Yes, the sparse function is an matrix.So,what I can’t understand is why it can plus by an element of an expression without error. It’s invalid in MATLAB that an element(or scalar) plus a sparse matrix.

Sorry I made a mistake,the expression is W(1:14,1:14).I’ll be more careful before asking question.

Thanks for your reply!