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?

 Respuesta aceptada

Guillaume
Guillaume el 30 de Ag. de 2017
Editada: Guillaume el 30 de Ag. de 2017

1 voto

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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (2)

KL
KL el 30 de Ag. de 2017
Editada: KL el 30 de Ag. de 2017

1 voto

nonzeros - EDITED
Use it in a Matlab function block?

5 comentarios

Guillaume
Guillaume el 30 de Ag. de 2017
The correct matlab function to get the non zero values is nonzeros. nnz just return how many non-zeros elements there are.
KL
KL el 30 de Ag. de 2017
So fast. Just about when it hit me and came back here to edit :D
Zhenteng Shen
Zhenteng Shen el 30 de Ag. de 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 el 30 de Ag. de 2017
No I mean, I want to use it with only simulink library components

Iniciar sesión para comentar.

Omur Bas
Omur Bas el 31 de Ag. de 2017

0 votos

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

Categorías

Más información sobre General Applications en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 30 de Ag. de 2017

Respondida:

el 31 de Ag. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by