Accessing array of structure datatype using simulink

Hello,
I'm am observing issue with using a for loop iterator with selector block. The For Iterator is looping from i= 0, i<5, i++ and the iteration variable (i) I'm passing it to selector block index through index vector port. The input to U of selector block is an array bus of size [1 42] whose datatype is structure of 4 elements. I need to loop through i value for accessing array elements. Screenshot is attached for simulink implementation and generated code.
In generated code, the index is always 0 even though the for loop is generated in the code.

回答 (1 件)

Karthik Ravishankar
Karthik Ravishankar 2020 年 11 月 10 日

0 投票

Are you sure, the for iterator should be zero based? Matlab arrays are 1 based.

1 件のコメント

Sneha Patne
Sneha Patne 2020 年 11 月 11 日
Yes, same output for when I changed to 1 based as well.

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

製品

リリース

R2019b

質問済み:

2020 年 11 月 10 日

コメント済み:

2020 年 11 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by