convert string to ascii

  • Follow


Hello
 Can anybody tells how to convert a string in Ascii values in matlab/

Thanks in advance
wait for reply..
0
Reply Mousmi 11/9/2010 11:56:08 AM

You can convert a string to a matrix of ASCII values by just wrapping it in double

> s=double('hello')

s =

   104   101   108   108   111

Convert back as follows

>> [char(s)]

ans =

hello

Hope this helps,
Mike
1
Reply Mike 11/9/2010 7:35:32 AM


hello Mike,
 Thanks alot. It works. Thanks again.

Mousmi
0
Reply Mousmi 11/9/2010 1:24:03 PM

On 09/11/10 5:56 AM, Mousmi Chaurasia wrote:

> Can anybody tells how to convert a string in Ascii values in matlab/

That is not generally possible, as Matlab strings are stored as 16 bit 
numbers and can include non-ASCII characters.

You also need to define *which* ASCII you are working with. There are 
several code sets that go by the generic name ASCII . One of those, 
US-ASCII, was later used as the foundation of the ISO Latin-1 font that 
then went on to become the first block of UNICODE, but if you happen to 
need one of the other ones then the conversion becomes more difficult.
0
Reply Walter 11/9/2010 3:40:27 PM

3 Replies
1276 Views

(page loaded in 0.068 seconds)

Similiar Articles:













7/22/2012 1:42:45 PM


Reply: