MATLAB: Subscripted assignment dimension mismatch error

subscripted assignment dimension mismatch error

Subscripted assignment dimension mismatch (size [1 x :?] ~= size [:? x :?]).
Hi, I m working on the code below and I need to convert it to C. When I use the MATLAB coder. It gives me this error.
M = [1 2 3 4;4 5 6 7;7 8 9 9;10 11 12 3;13 14 15 6];
rows = size(M,1);
col = size(M,2);
deg = 3;
var_deg = repmat(deg,[1,size(M,2)]);
max_deg = max(var_deg);
A = zeros(max_deg^col,col);
for i=1:col
A(:,i) = mod(floor((1:max_deg^col)/max_deg^(i-1)),max_deg);
end
A = fliplr(A);
A = A(sum(A,2)<=max_deg,:);
B = diag(repmat(max_deg,[1,col]));
A = [A;B];
N_in = size(A,1);
%X = zeros(rows,N_in);
for i=1:rows
P=repmat(M(i,:),[N_in,1]);
C=P.^A;
ran2=1;
for j=1:col
ran2=ran2.*C(:,j);
end
*X(i,:) = ran2;*
end
Here X(i,:) = ran2; in this line , it gives me the above error and I m not sure what to do. Please help!

Best Answer

Replace
ran2=1;
with
ran2 = ones(size(C,1),1);
so that you are not changing the size of ran2