Binary string to character string?

조회 수: 1 (최근 30일)
raktim banerjee
raktim banerjee 2011년 1월 25일
Hello Sir!
There is an binary string 'watermark', like this:
watermark =
00000000000000000000111111110111111000001111111111111111111100001000010010000000001001001001011111110011001110001010000010101100110100011111010100110011011000000000000000000000000000000000000000000000111111111111111111111111111110000000000000000001111111111111000111100000000000000110011001111111111110101010100000000000
whos watermark
Name Size Bytes Class
watermark 1x320 640 char array
Grand total is 320 elements using 640 bytes
I want to convert it into character string. The expected string is :
banerjee.raktim*****123456789***********
I wrote this:
>> char(bin2dec(watermark))
??? Error using ==> bin2dec
Binary string must be 52 bits or less.
How to do this?

채택된 답변

Matt Fig
Matt Fig 2011년 1월 25일
userid = char(bin2dec(reshape(watermark(1:160),[],8))).'
passwrd = char(bin2dec(reshape(watermark(161:320),[],8))).'
str = [userid passwrd]
  댓글 수: 1
raktim banerjee
raktim banerjee 2011년 1월 25일
Thank You Sir a lot! It works.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 1월 25일
This duplicates a question in #349
  댓글 수: 1
Matt Fig
Matt Fig 2011년 1월 25일
Not quite. This duplicates a question asked in the comments section of question #349. If the OP had been thinking thoroughly, he could have asked for a solution AND its inverse.

댓글을 달려면 로그인하십시오.

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by