フィルターのクリア

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 Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by