Error copying a segment of values from an input vector to a property vector with different sizes using MatLab Coder

1 visualización (últimos 30 días)
While trying to generate a mex file, I'm getting the error "Dimension 1 is fixed on the left-hand side but varies on the right ([16 x 1] ~= [:? x 1]) " in the line code below
obj.prevInput = u(idx);
where obj.prevInput is a fixed length propertie (16x1), u is fixed length (128x1) input, and idx is a variable vector of index that address a continuous segement of u with size (16x1). Althought, all assigments to idx have the size of obj.prevInput, idx size is being identify as (1x:inf) by Matlab Coder.
How do I fix this error?
I have attached my full system object code.

Respuestas (1)

Andy
Andy el 9 de Abr. de 2020
Codegen is not smart enough to realize that a:a+c has fixed size (1xc). So:
If you want to make idx fixed size, try changing the line:
idx = initIdx : initIdx+int16(obj.smplPerSymb-1);
to:
idx = initIdx + (0:int16(obj.smplPerSymb-1));
If you want to make the assignment to work with variable size idx you can do the following:
tmp = u(idx);
obj.PrevInput(:) = tmp(1:numel(obj.PrevInput))

Categorías

Más información sobre MATLAB Coder en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by