Extract non zero term from Vector

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
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 个评论

This gives the index but not the value I think
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
nonzeros - EDITED
Use it in a Matlab function block?

5 个评论

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

请先登录,再进行评论。

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

类别

帮助中心File Exchange 中查找有关 General Applications 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by