Hello, I have a 1 x 9 vector which contains all zeroes apart from one element which will take a +ve or -ve number, it's index will change, how do i extract this non zero number in Simulink? Is there a block for it?

 採用された回答

Guillaume
Guillaume 2017 年 8 月 30 日
編集済み: Guillaume 2017 年 8 月 30 日

1 投票

A quick search for "simulink nonzeros" returns as its first link this find block. If you set the Show output port for nonzero input values to true, then you'll get the nonzeros values.

2 件のコメント

Zhenteng Shen
Zhenteng Shen 2017 年 8 月 30 日
This gives the index but not the value I think
Guillaume
Guillaume 2017 年 8 月 30 日
As I wrote:
If you set the Show output port for nonzero input values to true, then you'll get the nonzeros values.

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

その他の回答 (2 件)

KL
KL 2017 年 8 月 30 日
編集済み: KL 2017 年 8 月 30 日

1 投票

nonzeros - EDITED
Use it in a Matlab function block?

5 件のコメント

Guillaume
Guillaume 2017 年 8 月 30 日
The correct matlab function to get the non zero values is nonzeros. nnz just return how many non-zeros elements there are.
KL
KL 2017 年 8 月 30 日
So fast. Just about when it hit me and came back here to edit :D
Zhenteng Shen
Zhenteng Shen 2017 年 8 月 30 日
I really want to do it on Simulink, and I actually want the value of the non zero number. Thanks
KL
KL 2017 年 8 月 30 日
Zhenteng Shen
Zhenteng Shen 2017 年 8 月 30 日
No I mean, I want to use it with only simulink library components

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

Omur Bas
Omur Bas 2017 年 8 月 31 日

0 投票

If all the other elements are zero, and you don't need the index, then Sum of Elements block would do the trick.

カテゴリ

ヘルプ センター および File ExchangeGeneral Applications についてさらに検索

製品

質問済み:

2017 年 8 月 30 日

回答済み:

2017 年 8 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by