How to convert a Ascii Text input to Binary Output

Hi, i am given an ASCII value as an input and i want to convert it into BINARY Output.

1 Comment

Hello Guys,could you tel me the meaning of this command line:-
function rem = binary_rem(input, genpol)
input = [input zeros(1,length(genpol)-1) 0];

Sign in to comment.

 Accepted Answer

Your question is a bit ambiguous, but this may be what you’re looking for:
asv = uint8('A')
asb = dec2bin(asv)
produces:
asv =
65
asb =
1000001

9 Comments

shall i also use this...:-
msg=str2num(msg)
so that i can also give a loop for "msg"...
Hello Guys,could you tel me the meaning of this command line:-
function rem = binary_rem(input, genpol)
input = [input zeros(1,length(genpol)-1) 0];
First, str2num converts a number represented as a string into a double-precision number, so:
q = str2num('A')
returns:
q =
[]
which is probably not what you want.
This line:
r = uint8('AaBbQqZz')
produces:
r =
65 97 66 98 81 113 90 122
that probably is what you want.
Second, the ‘binary_rem’ function takes the (badly-named) ‘input’ variable and concatenates a vector of zeros to the end of it. I have no idea what its purpose is in the script that calls it. (Note that input is a built-in MATLAB function. It is not a good idea to name a variable the same as a function, but here you can get away with it because it is local to the ‘binary_rem’ function only.)
yes.perfect...!!!
Thanks.
G F
G F on 12 Nov 2014
Edited: G F on 12 Nov 2014
But then what is the difference between uint8('') and uint32('')..??
ok i got it it is just the difference that it converts into 32 and 8 bit unsigned integer.
Correct. The difference is the number of bits used. For ASCII encoding, eight is enough.
Yes thanks again... :)

Sign in to comment.

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Asked:

G F
on 11 Nov 2014

Commented:

on 12 Nov 2014

Community Treasure Hunt

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

Start Hunting!