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

1 次查看(过去 30 天)
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 个评论
Denis Gurchenkov
Denis Gurchenkov 2016-10-7
(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,:);

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by