How can treat with a 0,1 number as a binary?!
조회 수: 3 (최근 30일)
이전 댓글 표시
Hi
could anyone please help me? I want to define A as a integer number:101011, but next i need to treat with this number as a binary format! for example i want get not from it! imagine i have D=[1 1 1 0 1 0 0 1 1 0 1] an i extract A=D(7:11)=01101 and want to get A_not=10010 but because of the integer nature of D, i can not do this! how can i do?
댓글 수: 3
Image Analyst
2018년 8월 27일
You cannot get leading zeros unless y is a string. It can't be a logical data type, integer data type, or double data type and have leading zeros unless you use fprintf() or sprintf() to display it as a string.
답변 (1개)
Image Analyst
2018년 8월 26일
You can use the logical() function.
D = [1 1 1 0 1 0 0 1 1 0 1]
A = logical(D(7:11))
A_not = ~A
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!