Convert logical variable into integer number
이전 댓글 표시
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!
채택된 답변
추가 답변 (2개)
Kehn Wu
2021년 12월 21일
0 개 추천
You could try sum()
Marcelo Moraes
2022년 1월 10일
0 개 추천
In HDC Coder you can use the block
HDL CODER => LOGIC AND BIT OPERATIONS => BIT CONCAT
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!