MATLAB: Coding error: The left-hand side has been constrained to be non-complex, but the right-hand side is complex. To correct this problem, make the right-hand side real using the function REAL, or change the initial assignment to the left-hand side vari

simulink

function xq = fcn(dq)
R=((0:(128-1))'-128/2-eps)/(1*128)+1/2;R(R<0)=0;R(R>1)=1;F=1-R;% Ramp rise/fall
R=R.^4.*(35 - 84*R+70*R.^2-20*R.^3);F=1-R;% Meyer auxiliary function
R=1/2*(cos(F*pi)+1);F=1-R;% Meyer RC rise/fall
R=sqrt(R);F=sqrt(F);%Meyer RRC
g=[F;zeros((8-2)*128,1);R];
g=g/sqrt(sum(g.^2));%normalization
% Frequency shift oqam
gi = g;
gq = ifft(circshift(fft(gi), 8/2));
w = exp(1j*2*pi/128);
n = 0:8*128-1; n=n';
Aq = zeros(8*128, 8*128
for k=0:128-1
for m=0:8-1
Aq(:,m*128+k+1) = 1i^(mod(m,2)+1)*circshift(gq, m*128) .* w.^(k*n); %error here
end
end
xq=Aq*dq;

Best Answer

Aq = complex( zeros(8*128, 8*128), zeros(8*128, 8*128));