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

Home » Public Forums » archive » Re: Working with lists
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Working with lists [message #84407 is a reply to message #84404] Mon, 03 June 2013 12:21 Go to previous messageGo to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Monday, June 3, 2013 7:39:46 PM UTC+2, fgg wrote:
> Hello,
>
>
>
> I have a string array that looks like this (with the exception that the numbers actually vary from element to element):
>
>
>
> str = replicate('1000 1000.1515 400 40', 10)
>
>
>
> Is there a simple way to extract these numbers to a 4 by 10 array without using loops? I've tried the following, but it doesn't work:
>
>
>
> str = strsplit(str, /extract)
>
> array = str.ToArray(type='float')
>
>
>
> % LIST::TOARRAY: Unable to convert to type FLOAT: Element 7
>
> % Error occurred at: LIST::TOARRAY
>
> % $MAIN$
>
> % Execution halted at: $MAIN$
>
>
>
> What's the problem with this?
>
>
>
> Thanks!

How about this:

IDL> str = strsplit(str, /extract)
IDL> str = replicate('1000 1000.1515 400 40', 10)
IDL> str = strsplit(str, /extract)
IDL> array = float(str.ToArray() )
IDL> help, array
ARRAY FLOAT = Array[10, 4]
IDL> print, array[*,0]
1000.00 1000.00 1000.00 1000.00 1000.00 1000.00 1000.00 1000.00 1000.00 1000.00

Cheers,
Helder
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: points on a plot
Next Topic: Subscript by -1 HARD to Track Down

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

Current Time: Fri Oct 10 16:55:10 PDT 2025

Total time taken to generate the page: 0.16021 seconds