필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
Tyler
Tyler 2017년 4월 26일
댓글: Walter Roberson 2017년 5월 8일
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?
Regards,
Tyler

답변 (1개)

Sanjana Ramakrishnan
Sanjana Ramakrishnan 2017년 5월 8일
S-Functions support variable size signals. Refer the below link for more information:
https://www.mathworks.com/help/simulink/ug/s-functions-using-variable-size-signals.html
  댓글 수: 1
Walter Roberson
Walter Roberson 2017년 5월 8일
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.)

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by