フィルターのクリア

Get array size in Simulink

207 ビュー (過去 30 日間)
Thomas LE DIOURON
Thomas LE DIOURON 2012 年 10 月 18 日
コメント済み: Shankar Santhosh 2021 年 2 月 26 日
Hello,
I would like in Simulink have a block with an array as parameter. This array could have various size. In this code, I want to extract a specific element.
I tried to do this with a selector block to select the desired element and a size "Matlab function" to avoid an out of bounds conflicts.
However, the selector block needs to specify the input port size (wich is not always the same). Moreover, for example, for an array [10 12 17 20], how to extract the 4 from the 1x4 result of the size command?
Any idea?
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 18 日
編集済み: Azzi Abdelmalek 2012 年 10 月 18 日
Can you specify where your array is coming from. Is it an output of another block or it's just an input to other blocks. Is your array size changing during simulation?

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

採用された回答

Sachin Ganjare
Sachin Ganjare 2012 年 10 月 18 日
You can use 'Width' block from simulink library.
Hope it helps
  1 件のコメント
Shankar Santhosh
Shankar Santhosh 2021 年 2 月 26 日
Is there any alternate method to find the size than using 'width' block?
Because I have a requirement to create the model in Targetlink and not all Simulink blocksets are supported(especially this width block).

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

その他の回答 (2 件)

Thomas LE DIOURON
Thomas LE DIOURON 2012 年 10 月 18 日
Thanks for this answer. With the help of this block and the "select rows" block, I have all that needed.

javad sh
javad sh 2015 年 4 月 22 日
I also used this method and found it useful\
I am reading from a serial port and i needed to know the length of massage that i am reading
now the problem that i have is this block will overflow if it become more than 255 what can we do when we have more than 255 byte to analysis
thank you for reply
fazareh
  1 件のコメント
Ali Bars Gunduz
Ali Bars Gunduz 2018 年 10 月 12 日
You can use demux block to divide your array into 255 element arrays and compute each arrays lengths

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

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by