Charecter to binary form
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
I have a character A. I converted this into a binary form(say B). I need to perform some operations using B. While doing this I need to check whether the element B(1)=1 or 0.
For doing so, I write
if B(1)==1
But it doesn't work. It works when I written like this-
if B(1)=='1'
What is the reason? Please tell me...
채택된 답변
  Oleg Komarov
      
      
 2013년 1월 30일
        You are comparing the char '1' with the numeric 1.
>> double('1')
ans =
    49
as in the ASCII table.
You have to rescale '1' to 1:
'1'-'0' == 1
and in your case
B(1)-'0' == 1
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



