![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1654961/image.png)
I'd like to know how to use Simulink's Bitwise Operator Block to find when a specific bit's value is 1.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sarang
el 29 de Mzo. de 2024
Respondida: Jongil Lee
el 29 de Mzo. de 2024
I want to identify when the 9th bit is set to 1 as depicted in the diagram below. So, I've structured the model as shown.
I expected the output of the Bitwise Operator Block 4 to be 1, but it's showing as displayed below. I configured it as follows.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1654866/image.png)
I think the only way to mask the value of the 9th bit as I initially intended is by changing the value of 'constant4' to 512. I'm wondering if I've understood this correctly.
0 comentarios
Respuesta aceptada
Jongil Lee
el 29 de Mzo. de 2024
안녕하세요
의도하시는 로직의 결과가 10진수 512와 16진수 0x200의 bitwise AND operation이지만 그 결과도 정수로 표현되기에 true/false라는 개념으로 나타나지 않습니다. 해당 자릿수에 0 또는 1을 판단하고 싶으시다면 AND operation 다음에 bit shift를 통해 확인하시거나 Extract Bit Block을 이용해 원하시는 비트를 추출해 보시기 바랍니다.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1654961/image.png)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!