Convert logical variable into integer number
Mostrar comentarios más antiguos
Hi! I think my problem is very simple. I have some boolean expressions in my code, which the results will always be 1 or 0 (true or false). Here are some examples:
data=data+(-1*(~mat(i)&&mat(j)&&mat(k)))||(~mat(i)&&~mat(j));
or
data=data+(~mat(i));
I have to convert these logicals 1s and 0s to int values. I've tried using abs() but it is not working.
Btw, I'm on R2015b.
I appreciate the help.
Thanks!
Respuesta aceptada
Más respuestas (2)
Kehn Wu
el 21 de Dic. de 2021
0 votos
You could try sum()
Marcelo Moraes
el 10 de En. de 2022
0 votos
In HDC Coder you can use the block
HDL CODER => LOGIC AND BIT OPERATIONS => BIT CONCAT
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!