Borrar filtros
Borrar filtros

How to handle logical arrays in Simulink?

4 visualizaciones (últimos 30 días)
Utku
Utku el 20 de Dic. de 2023
Comentada: Sulaymon Eshkabilov el 20 de Dic. de 2023
I have a logical comparison of an array in Simulink. I need to use any() function in MATLAB to handle the output of the comparison but I realized there is not any representation of this function in Simulink library. Is using MATLAB Function block the only way to use any() or all() functions in Simulink? Is there any particular reason that these do not exist in Simulink library? How do you handle logical arrays in Simulink?
  1 comentario
Utku
Utku el 20 de Dic. de 2023
To be more specific, for example, I do the logical operation "[1 2 3 4 5] == 2" in Simulink, and the output is a logical array which is [0 1 0 0 0], but I need a single output as 1 in this case.

Iniciar sesión para comentar.

Respuesta aceptada

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 20 de Dic. de 2023
Yes, it can be worked around - see this plain model:
  2 comentarios
Utku
Utku el 20 de Dic. de 2023
Thank you very much! I gues this is the only proper way other than using MATLAB function
Sulaymon Eshkabilov
Sulaymon Eshkabilov el 20 de Dic. de 2023
Most welcome! Glad to be of some help.

Iniciar sesión para comentar.

Más respuestas (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 20 de Dic. de 2023
Of course Simulink blocks can be used. Simulink library has a bunch of logic operation blocks - follow to see them: Simulink -> Logic and Bit Operations.

Sulaymon Eshkabilov
Sulaymon Eshkabilov el 20 de Dic. de 2023
See this screenshot:
  1 comentario
Utku
Utku el 20 de Dic. de 2023
Thank you for your answer, but I need a single output from an array comparison. All of these do not do the same job that any() function does in MATLAB.

Iniciar sesión para comentar.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by