LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

spreadsheet string to array complex data

I have an array of strings with each line containing a complex number in the format "+/-.934343 +/-3.343242 i".  Is it possible to convert this to a complex double array somehow?  I have used spreadsheet string to array and obtained the array of strings.  are there any suggestion on how to convert this array of strings to an array of complex doubles?
Regards
0 Kudos
Message 1 of 4
(2,658 Views)
I'm not big on complex numbers, so I'm not sure what the +/- stands for, but if it's always there, then it doesn't mean anything, so you can use String Subset to remove the first part of the string, then use search\split string to find the second +/- and use Fract/Exp string to number twice to get the 2 numbers. Wire the 2 numbers into Re/Im to Complex (in the Numeric>>Complex palette) and you have your complex number. Do this in a for loop and you have an array.

___________________
Try to take over the world!
0 Kudos
Message 2 of 4
(2,652 Views)
I wrote a SPICE (Circuit ananlysis program) post processor in LV recently. The SPICE complex format is slightly different from yours but you may be able to adapt it. The SPICE format is "\s0\t1.000000000e-03,0.000000000e+00\n\t2.000000000e-02,0.000000000e+00\n".

The first field "space0" is a time stamp of type integer. The second field is a comma separated complex number in scientific format. Successive rows with empty timestamp fields are the complex values for successive variables. After all the variables are listed for timestamp 0, a blank line is inserted and then the data for timestamp 1 starts.

Let me know if you are interested in my VI.

Lynn
0 Kudos
Message 3 of 4
(2,648 Views)
the +/- in my orignal post means that the value may have negative sign which preceeds it.  in other words, the value may be positive or negative.  an example would be 3.3423-3.44342i  or -34.4543+31.34342i
I will work on trying to parse it into two pieces.
Thanks
Bryan
0 Kudos
Message 4 of 4
(2,644 Views)