Assign values to an array based on an if statement from a larger array
古いコメントを表示
Hi,
I have an 20 elements array (uint8) in which some elements can be '0' and I want to retrieve the first 8 values that are not '0' and assign them to another array (uint8).
I am constrained to using only slcilib blocks and submodules so the sorting option is not usable.
So far I have done something like this

However, it seems that the for loop never ends and I have to manually stop the model using ctrl + C.
Does anyone have an idea about this issue?
4 件のコメント
Ayush Singh
2024 年 2 月 12 日
Are you allowed to make use of S function to implement the above logic?
Mathieu
2024 年 2 月 12 日
Fangjun Jiang
2024 年 2 月 12 日
編集済み: Fangjun Jiang
2024 年 2 月 12 日
I would use the MATLAB Function block. On the other hand, I don't think you are using the For Iterator block correctly. Take a look at the doc and example model.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!