MATLAB Answers

Extract non zero term from Vector

10 views (last 30 days)
Zhenteng Shen
Zhenteng Shen on 30 Aug 2017
Answered: Omur Bas on 31 Aug 2017
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?

  0 Comments

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 30 Aug 2017
Edited: Guillaume on 30 Aug 2017
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 Comments

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

Sign in to comment.

More Answers (2)

KL
KL on 30 Aug 2017
Edited: KL on 30 Aug 2017
nonzeros - EDITED
Use it in a Matlab function block?

  5 Comments

Show 2 older comments
Zhenteng Shen
Zhenteng Shen on 30 Aug 2017
I really want to do it on Simulink, and I actually want the value of the non zero number. Thanks
Zhenteng Shen
Zhenteng Shen on 30 Aug 2017
No I mean, I want to use it with only simulink library components

Sign in to comment.


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

  0 Comments

Sign in to comment.