Borrar filtros
Borrar filtros

Can a variable length signal be converted to a fixed length signal?

4 visualizaciones (últimos 30 días)
Tyler el 26 de Abr. de 2017
Comentada: Walter Roberson el 8 de Mayo de 2017
I start with a uint8 array. From this array I parse out both numeric and text values, but of course, the text values are actually uint8's since Simulink does not support strings.
The problem with parsing out the text values is that their length is variable, and as a result the signal resulting from this parsing contains a variable size array. The parsing is done in a MATLAB function block, which I guess prevents Simulink from inferring the size of the output signal.
A variable length signal would not be a problem if the s-function I wanted to give it to could receive a variable size array. Lastly, as a point of information, whatever I do MUST BE supported for code generation on a Raspberry Pi.
So I have two-questions:
  1. Am I missing something with s-functions and they CAN take variable size arrays as inputs?
  2. If I'm not missing something with s-functions, can the variable size signal be converted to a fixed size somehow, which would enable me to pass it to the s-function?

Respuestas (1)

Sanjana Ramakrishnan
Sanjana Ramakrishnan el 8 de Mayo de 2017
S-Functions support variable size signals. Refer the below link for more information:
  1 comentario
Walter Roberson
Walter Roberson el 8 de Mayo de 2017
Also, the way to handle the variable length strings is to define a maximum string length; with the facilities described above, code can be generated to handle up to the defined maximum size.
Coding for truly unlimited strings is risky for hardware targetting, as you could end up asking for more memory than is available on the hardware; or even before that, you could end up exceeding the space that has been put aside for the stack. When you code for fixed array sizes, the compiler can (theoretically) construct call trees to determine the maximum stack usage, and adjust the stack / heap boundary point from that.
(I have not investigated to determine whether the Raspberry Pi grows the stack "upwards" or "downwards" so I am not certain how much of an issue stack placement is on the Raspberry Pi; it can certainly be important on some hardware targets.)

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by