# Matrix dimensions must agree: Real Affine Expression

Hi All,
I need to resolve this error. I am trying to multiply Real affine Expression. Please read as. I have a small problem here. I have P as: cvx real affine expression (1x2x5 array) and I am trying to multiply it with h which is
h = 1.0e-12 *

``````0.0419
0.1723 as:
``````

Expression for multiplication:

## sum(sum(sum(B.*(log(1 + (P.*h)/NoB))/log(2)))) >= B

My error is: Error using .* (line 46)
Matrix dimensions must agree.

## Error in small_example (line 18) sum(sum(sum(B.*(log(1 + (P.*h)/NoB))/log(2)))) >= B

``````%%% CODE start here.
m = [1];
k = [1 2];
u = [1 2 3 4 5];
NoB = 0.1*10^-12;
alpha = 5;
beta = exp(1); %length(m)*length(k)*length(u)
d = normrnd(375,125,[length(k),1]);
B = 5*10^6;
h = beta*(d.^(-alpha));
%%
cvx_begin
variable P(length(m),length(k),length(u))
sum(sum(sum(P))) <= 0.5
sum(sum(sum(B.*(log(1 + (P.*h)/NoB))/log(2)))) >= B``````

(Mark L. Stone) #2

`P.*h` is not conformal. If P were a 1 by 2 by 5 MATLAB variable instead of CVX variable, `P.*h` would be rejected by MATLAB. I don’t know what you really want this to be, but if it isn’t valid (conformal) with MATLAB variables, it won’t be valid when some or all of them are CVX variables. Also `B.*<stuff>` will be valid, but I don’t know why you use`.*` because it will be the same as `*` . .I don’t know what you are trying to do. Perhaps you can eliminate the B on both sides of the inequality?

Once you get that fixed, you may still experience difficulties due to horrible scaling. Dividing by numbers such as 1e-13 inside the log is not likely to work out well with the solver.