concerverting a vetor to string [message #45909] |
Thu, 20 October 2005 12:46  |
Francois L.
Messages: 19 Registered: December 2004
|
Junior Member |
|
|
Hello,
I have a vector A (integers):
> A = [1,2,3,4]
that I want to convert into a string.
If I use the command
> B = string(A)
then B is a string of four elements.
How can I convert A to string in order to have '1234' ? which is not an
array of four elements...
Well at the end, I want to convert '1234' into the number 1234.
Thank you,
Franois Leduc
|
|
|
Re: concerverting a vetor to string [message #45996 is a reply to message #45909] |
Thu, 20 October 2005 23:41  |
peter.albert@gmx.de
Messages: 108 Registered: July 2005
|
Senior Member |
|
|
Hi Francois,
try
IDL> a=[1,2,3,4]
IDL> b=fix(strjoin(strcompress(string(a),/rem)))
IDL> print, b
1234
So, string(a) makes a 4-elemen array of strings, strcompress(,/rem)
removes all blanks from the individual strings, strjoin() puts them all
together into one, and finally fix() converts the one string into a
number.
Cheers,
Peter
|
|
|