Simulink size mismatch problem

7 次查看(过去 30 天)
Idan
Idan 2013-8-26
Simulation stopped due to size mismatch error on dimension 2: expected 1 but actual size is 6912.
The debugger pointer (green arrow) is on the line: OUT_decode=zeros(24*floor(length(IN_enc)/32),1)';
At the beginning I tried to work with matrices format on the line "OUT_decode(1+(ii-1)*24:24*ii)=k(1:24);" but gut a weird error- Matrix(matrix) subscript turned out to be a vector(vector) subscript simulink
here is the relevant code:
function OUT_decode =viterbi_decode_obj(IN_enc,R)
%#codegen
% IN_enc=IN_enc';
persistent tb_len trellis
if(isempty(tb_len))
tb_len=length(IN_enc)/2;
trellis=poly2trellis(7,[133 171]);
end
switch R
case{9,18,36,54} % R=3/4
OUT_decode=zeros(24*floor(length(IN_enc)/32),1)';
for ii=1:floor(length(IN_enc)/32)
k= viterbi_dec_3(IN_enc((1+(ii-1)*32):ii*32),16);
OUT_decode(1+(ii-1)*24:24*ii)=k(1:24);
end
otherwise
OUT_decode=zeros(1,2)';
end % end switch
% OUT_decode(1:end)=OUT_decode1(1:end);
return
function [OUT_dec] =viterbi_dec_3(IN_enc,tb_len)
%#codegen
% OUT_dec=(zeros(24,1));
persistent hDec
if(isempty(hDec))
trellis=poly2trellis(7,[133 171]);
hDec = comm.ViterbiDecoder(trellis,'InputFormat','Hard','PuncturePatternSource','Property', 'TerminationMethod','Truncated','PuncturePattern',[1;1;1;0;0;1],'TracebackDepth',24 );
end
IN=IN_enc;
OUT_dec=double(zeros(tb_len,1));
OUT_dec = step(hDec, IN);
% OUT_dec=OUT_dec';
return

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Naming Conventions 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by