Extract rows from a matrix input signal in TLC files

1 ビュー (過去 30 日間)
John Borek
John Borek 2018 年 8 月 9 日
コメント済み: John Borek 2018 年 8 月 10 日
For code generation of my level 2 S-function, I need to inline my S-function in a TLC file. I'm new to this, so I'm experimenting with the 'timestwo' example. I now know how to extract individual elements from a signal that is a 1D array, but what I don't know is how to extract multiple elements from a larger array as a single variable (e.g. extract [1 2] from [1 2 3]). I ultimately need to extract individual rows from a matrix I input into the S-function as separate variables (e.g. extract [1 2] from [1 2; 3 4]).

採用された回答

TAB
TAB 2018 年 8 月 10 日
編集済み: TAB 2018 年 8 月 10 日
I assume you are trying to inline S-function for C-code generation.
Simulink Coder (and also Embedded Coder) handles 2-D array as 1-D.
So even if there is 2-D array (Signal or parameter) in your model, it will be handles as 1-D array in generated code.
So TLC also don't provide any option/function to access an array as 2-D.
For your inlining TLC, you can handle 2-D array as 1-D OR before passing the Simulink 2-D array to S-function, split into 1-D array. This is best option in my opinion.
  1 件のコメント
John Borek
John Borek 2018 年 8 月 10 日
Okay, thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Find more on Code Generation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by