Element-wise multiplication of 3-dimensional arrays


I have an array of a 1000 2x2 matrices that I store in the array matrices of dimension size(matrices) = (2,2,1000). In standard Matlab syntax, if I have a thousand constants c = [c1, c2, c3, ..., c1000] I can multiply each constant with a corresponding matrix by doing the following:

cmatrices = matrices .* reshape(c,[1,1,1000])

which gives cmatrices = [c1*matrices(:,:,1), c2*matrices(:,:,2), ...].

I would like to do the same in CVX, namely set a variable c(1000) and perform matrices .* reshape(c,[1,1,1000]). However, it seems that CVX explicitly does not support these operations, as the CVX file times.m throws an error that the matrix dimensions do not agree.

Why is this operation not allowed in CVX? Can I get around this limitation?

(Michael C. Grant) #2

The ability to multiple mismatched matrices like this is actually a new feature of MATLAB, and CVX has not yet been updated to support it.