필터 지우기
필터 지우기

How to fix Non-constant expression or empty matrix

조회 수: 1 (최근 30일)
San
San 2012년 7월 8일
Help me please.
There is any different between following codes?
Case 1:
m_intrlvr = zeros(10,1);
m_intrlvr(1) = 4;
m_intrlvr(2) =7;
m_intrlvr(3) =10;
m_intrlvr(4) =3;
m_intrlvr(5) =6;
m_intrlvr(6) =9;
m_intrlvr(7) =2;
m_intrlvr(8) =5;
m_intrlvr(9) =8;
m_intrlvr(10) =1;
persistent hTBCode;
if isempty(hTBCode )
hTBCode = comm.TurboEncoder('TrellisStructure', ...
poly2trellis(4,[13 15], 13), 'InterleaverIndices', m_intrlvr);
end
Case 2:
m_intrlvr = [4;7;10;3;6;9;2;5;8;1];
persistent hTBCode;
if isempty(hTBCode )
hTBCode = comm.TurboEncoder('TrellisStructure', ...
poly2trellis(4,[13 15], 13), 'InterleaverIndices', m_intrlvr);
end
The first case it raise error: Non-constant expression or empty matrix. This expression must be constant because its value determines the size or class of some expression. Internal Error: This error occurred inside a MathWorks function.
P-code function 'pvparse.p' produced an error.
but the second one it is ok. anyone can help me where is my wrong?
(Re-opened)
  댓글 수: 4
Walter Roberson
Walter Roberson 2012년 7월 8일
Then I suspect it is trying to do code generation and that the code needs to conform to the Embedded MATLAB standards.
My (weak) knowledge is that m_intrlvr = zeros(10,1) should work for that situation. It would, however, not necessarily work if really the code was
numvals = 10;
m_intrlvr = zeros(numvals, 1);
Though it might in that particular case as it can see numvals as a constant. If the number of values was being passed through a signal then it would not work.
Which MATLAB version are you using? I have a vague memory of someone mentioning a bug in the automated code generation, a small number of releases ago.
San
San 2012년 7월 8일
편집: Walter Roberson 2012년 7월 9일
>Which MATLAB version are you using?
I'm working with R2011b
it look better when put the script in separately function file. Thanks for your supporting.

댓글을 달려면 로그인하십시오.

답변 (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