# How I can fix this problems

``````clear all
clc
for N=8:2:20
tn = 7;
M = 7; L = 5;
attSR = -40; attPU = -60; % dB
Nt = N;
h = zeros(Nt,M); % Nt antenna to M SRs
g = zeros(Nt,L); % Nt antenna to L PUs

for ii=1:M % to each SRs
h(:,ii) = (1/sqrt(1/attSR))* sqrt(1/2)*(randn(Nt,1)+1i*randn(Nt,1)) ;
H(:,:,ii) = h(:,ii)*h(:,ii)'; %before (7a) to 1 SR
end
for ii=1:L
g(:,ii) = (1/sqrt(1/attPU))* sqrt(1/2)*(randn(Nt,1)+1i*randn(Nt,1)) ;
G(:,:,ii) = g(:,ii)*g(:,ii)' ; %before (7a) to 1 PU
end
end``````

When i compile this code, it’s appear this error.

Your post is off-topic, because it doesn’t even involve CVX (even if it might be generating input data for a CVX problem). You should post MATLAB questions not involving CVX at https://www.mathworks.com/matlabcentral/answers/index . I will give you a one time freebie, but will not answer non-CVX questions in the future.

When the for N = for loop is executed for the first time, `H` is created, and by the end of that time through the for loop, `H` is 8 by 8 by 7, which is o.k., in that time through the for loop, because `h(:,ii)*h(:,ii)'` is 8 by 8. However, the 2nd time through the for loop, when `H ` is still 8 by 8 by 7, the h(:,ii)*h(:,ii)’ which you try to assign to `H(:,:,ii)` is 10 by 10. Hence the MATLAB error message.