Is there a simple way to count zeros in vector in Simulink?

5 Ansichten (letzte 30 Tage)
HaniGhani
HaniGhani am 27 Dez. 2015
Beantwortet: Sebastian Castro am 27 Dez. 2015
I need to know how many zeros in a vector variable. for example variable X = [1 2 0 3 4 0], need to count zeros which is in this case 2. I have it in m-script as Y = length(find(X == 0)), but in Simulink the only way I found is to use "for loop", and compare each element in the vector and put a counter. I wonder if there is a simple way.

Antworten (1)

Sebastian Castro
Sebastian Castro am 27 Dez. 2015
You should be able to use that same MATLAB expression inside a MATLAB Function block.
- Sebastian

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by