MATLAB coder gives error while assigning value to the matrix (Subscripted assignment dimension mismatch (size [1 x :?] ~= size [:? x :?]).)

list_size=4;
LLR=zeros(list_size,2*N-1);
initialLRs = zeros(N,1);
initialLRs = -(4*sqrt(Ec)/N0) * y ;
for m=1:list_size
LLR(m,N:2*N-1) = initialLRs;
end
MATLAB coder gives this error "Subscripted assignment dimension mismatch (size [1 x :?] ~= size [:? x :?])." at line 5. "y" is also a matrix of size (N,1). When i run the code without MATLAB coder it runs fine and gives no error. What can i do to remove this error ? Or is there any efficient way of doing what i am doing in this code ?

1 Comment

(As you only showed an snippet of the code, not the whole function, I can't just run it and see what is wrong, so below is just my guess)
Is initialLRs a vector or a matrix? If you run this code in MATLAB, stop inside the loop and size(initialLRs), what it is?
coder thinks initialLRs is a matrix, whereas you are trying to assign it into a vector (LLR(m,:) is a 1-by-someting vector) thus the error.
Maybe you meant zeros(1,N) one thirst assign to initialLRs?
If you are confident that the code is correct, the way to silence the error is to change
LLR(m,N:2*N-1) = initialLRs;
to
LLR(m,N:2*N-1) = initialLRs(1,:);

Sign in to comment.

Answers (0)

Products

Asked:

on 16 Sep 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!