How to fix Non-constant expression or empty matrix
1 view (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 8 Jul 2012
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.
Answers (0)
See Also
Categories
Find more on Error Detection and Correction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!