comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » concerverting a vetor to string
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
concerverting a vetor to string [message #45909] Thu, 20 October 2005 12:46 Go to next message
Francois L. is currently offline  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 Go to previous message
peter.albert@gmx.de is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: L1 Norm?
Next Topic: map_set miracle

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:09:59 PDT 2025

Total time taken to generate the page: 0.00566 seconds