LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

split commas delimited into 1D complex array

Solved!
Go to solution

I have comma delimited string in this format

[0.866405665874481,0.127425819635391,0.983153462409973,-0.0711551383137703,0.955700755119324,-0.27884304523468,0.787182509899139,-0.501964211463928,0.512355387210846,-0.687117278575897,0.177220240235329,-0.777789652347565,-0.0876994803547859,-0.792799115180969,-0.324512422084808,-0.736825287342072,-0.517065346240997,-0.627932071685791,-0.666604995727539,-0.471743047237396,-0.767350137233734,-0.287838608026505,-0.819185018539429,-0.0853987112641335,-0.81872695684433,0.123056441545486,-0.761552691459656]

 

The data contains pairs of complex numbers.  The first 2 numbers is one pair, next 2 numbers one pair, next pairs.....

How can I extract the pairs of number and make it into a 1D complex array?

 

This is the expected output:

(0.866405665874481,0.127425819635391),(0.983153462409973,-0.0711551383137703),(0.955700755119324,-0.27884304523468),(0.787182509899139,-0.501964211463928),(0.512355387210846,-0.687117278575897),(0.177220240235329,-0.777789652347565),(-0.0876994803547859,-0.792799115180969),(-0.324512422084808,-0.736825287342072),(-0.517065346240997,-0.627932071685791),(-0.666604995727539,-0.471743047237396),(-0.767350137233734,-0.287838608026505),(-0.819185018539429,-0.0853987112641335),(-0.81872695684433),(0.123056441545486,-0.761552691459656)

 

Any gurus pls advise

Thanks and great day
0 Kudos
Message 1 of 3
(2,827 Views)

I would use Match Regular Expression to parse the input string. Regular expression (\d+.\d+),(\d+.\d+) gives two submatches, which can be converted to numbers. Then you can loop through remaining string to get the next pair.

--
Marko H

OptoFidelity - Enabling Smarter Future

Tampere - Espoo - Oulu - Cupertino - Redmond - Zhuhai

0 Kudos
Message 2 of 3
(2,823 Views)
Solution
Accepted by topic author LV_NewBoy

I used the Spreadsheet String to Array, Decimate Array, and then Re/Im to Complex.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(2,819 Views)