LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble converting array to spreadsheet string, storing the file and coverting back to array with complex numbers

I am working with a network analyzer. I have arrays made of 5 columns the first consisting of an integer and the next four consisting of complex numbers. I am converting the array into a spreadsheet string and then saving the file using the write characters to a file VI. That seems to work well as when I open the file in Excel all the data is there. However when I try to reverse the process, open file and convert back to array, I loose some of the data. Specifically the imaginary parts of my complex numbers are all going to zero. I have narrowed down the problem to be in the conversion from spreadsheet string to array and vice versa. I
think the problem may be with the 'format' input to the VI. I do not have an adequate resource for this so I am not sure what to put in to accomplish my task. Any takers?
0 Kudos
Message 1 of 4
(2,844 Views)
The problem is that the function: 'spreadsheet string to array' cannot handle complex numbers. The solution is to create your own sub-vi to parse the string or use the one I created. I did this in LabVIEW 6, if you need I can resave it in 5.x
0 Kudos
Message 2 of 4
(2,844 Views)
Hi Biz

I don't think there is a direct way of converting a complex number to a
string, so when you convert the array to a spreadsheet string, the
numbers would be converted to real data.

However, you could try separating the real and imaginary parts using the
"Numeric: Complex to Re/Im" function, and then store these - either in
separate files or in adjacent columns/rows in the same file. Then, when
you read in the data again, use the "Numeric: Re/Im to Complex" function
to put the two "halves" together.

If you actually want Excel to interpret the numbers as imaginary, then
you'll probably want to create a string for each complex number of the
form "Re + Im*i" (after separating the Re and Im parts), by using
"String:Format into String" with 2 numeric inputs and the format string
"%f+%fi".

Reading the data back into Labview then would require splitting the
string into the 2 pieces by using "String:Scan from String" with 2
numeric outputs (smae precision as original numbers specified by the 2
Default Value inputs) and the same format string "%f+%fi", and then using
the above-mentioned "Numeric: Re/Im to Complex" function. It worked for
me, so if you can't follow what I am describing, send me an email and I
can email you what I did (LV 5.1.1).

Paul

Biz wrote:

> Having trouble converting array to spreadsheet string, storing the
> file and coverting back to array with complex numbers
>
> I am working with a network analyzer. I have arrays made of 5 columns
> the first consisting of an integer and the next four consisting of
> complex numbers. I am converting the array into a spreadsheet string
> and then saving the file using the write characters to a file VI. That
> seems to work well as when I open the file in Excel all the data is
> there. However when I try to reverse the process, open file and
> convert back to array, I loose some of the data. Specifically the
> imaginary parts of my complex numbers are all going to zero. I have
> narrowed down the problem to be in the conversion from spreadsheet
> string to array and vice versa. I think the problem may be with the
> 'format' input to the VI. I do not have an adequate resource for this
> so I am not sure what to put in to accomplish my task. Any takers?

--

Research Assistant
School of Physiotherapy, Curtin University of Technology
Selby Street, Shenton Park, Western Australia, Australia. 6008
email: P.Davey@curtin.edu.au
Tel. +61 8 9266 4657 Fax. +61 8 9266 3699

"Everyone who calls on the name of the Lord will be saved." Romans 10:12
"For all have sinned and fall short of the glory of God, and are
justified freely by his grace through the redemption that came by Christ
Jesus." Romans 3:23-4
0 Kudos
Message 3 of 4
(2,844 Views)

i had the same problem but it got solved by using the solution of separating the real and imaginary numbers as mentioned above.

however i thought of a simple and better way of doing it. i am using 8.6 and in that htere is this feature of flatenning data to string.

i am using this function and storing the data in the form of string. i dont know what conversion does labview do but it works.

however i am facing a problem.. my data exceeds 40,000 complex numbers and i cannot read that data once i store it.. labview gives an error. in help file following is written for Read from Text File Function

 

count is the maximum number of characters or lines the function reads. The function reads fewer characters or lines if it reaches the end of file first. If count is <0, the function reads the entire file. The default is to read a single line if you placed a checkmark next to the Read Lines shortcut menu item and to read the entire file if you removed the checkmark next to the item."

If you wire a file size with a data type other than a 32-bit integer to count, LabVIEW coerces the data type to a 32-bit integer. This means the VI may not read the amount of data you intend. If you wire –1 to count and the size of the file you want to read is too large to be represented by a 32-bit integer, LabVIEW returns an error.

so my question is that is it possible that for 40K complex numbers the size of the file indeed becomes too large?
 
thanks 
0 Kudos
Message 4 of 4
(2,326 Views)