How to fix Non-constant expression or empty matrix

3 visualizaciones (últimos 30 días)
San
San el 8 de Jul. de 2012
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 comentarios
Walter Roberson
Walter Roberson el 8 de Jul. de 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.
San
San el 8 de Jul. de 2012
Editada: Walter Roberson el 9 de Jul. de 2012
>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.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Audio Plugin Creation and Hosting en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by