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!