Can a variable length signal be converted to a fixed length signal?
4 ビュー (過去 30 日間)
古いコメントを表示
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:
- Am I missing something with s-functions and they CAN take variable size arrays as inputs?
- 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
0 件のコメント
回答 (1 件)
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
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!