??? Dimension 1 is fixed on the left-hand side but varies on the right ([256 x 256] ~= [:? x :?]) when running codegen command
조회 수: 10 (최근 30일)
이전 댓글 표시
I ran into a weird issue when running codegen in matlab. I am aware that codegen requires you to predefine all the variables used. In this case, I predefined Dec as a cell array of cell arrays with each index corresponding to a m x n matrix.
nD = length(D);
kDec = A;
[m,n] = size(A);
Dec = cell(1,L);
for c = 1:L
Dec{c} = cell(nD-1);
for i = 1:nD-1
for j = 1:nD-1
Dec{c}{i,j} = zeros(m,n);
end
end
end
for k = 1:L
Dec{k} = FraDec(kDec,D,k);
kDec = Dec{k}{1,1};
end
kDec is predefined as a Matrix and therefore by equating kDec to Dec{k}{1,1}, there shouldn't be any issues in the matrix size allocation since both kDec and Dec have been predefined and each entry to Dec has been instantiated to a matrix of the same size. However when running codegen, I get the error ??? Dimension 1 is fixed on the left-hand side but varies on the right ([256 x 256] ~= [:? x :?]) for line:
kDec = Dec{k}{1,1};
After spending a very long time on this error, I have no idea how I can resolve this issue.
댓글 수: 2
Darshan Ramakant Bhat
2020년 10월 27일
Can you please attach the full sample code along with the full reproduction steps. This will help us to reproduce the issue at our end.
채택된 답변
Darshan Ramakant Bhat
2020년 10월 28일
I have modified the sample code attached and made it work.
Please use "codes_modified" file and run below command :
codegen SplitBregDebP.m -args {g,ker,mu,lambda,tol,frame,Level,wLevel,maxit,img} -report
The "-report" option will generate a codegen report and that will help you to debug the issue. Please refer below doc :
I have made use of coder.varsize() to make the code work. You can read below doc for more information :
There are some limitations when you are using cell arrays for codegeneration :
Hope this will be helpful for you.
댓글 수: 3
Darshan Ramakant Bhat
2020년 10월 29일
As I mentioned in my answer, you would have run into the cell array problem as mentioned in the doc :
Please try the methods suggested in the doc.
Please take a look at line 31 and 32 of "FraDecMultiLevel.m" file. Compare the code, before and after the modification that I did. You may follow the same approach for your code.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!