From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real number string to array

Solved!
Go to solution

Hello

 

I want to read real numbers from a text file and put them in an array.

The problem is the precision of the number is not shown. It is converted to integer.

 

There is a similar example at http://forums.ni.com/t5/LabVIEW/Text-string-to-integer-array-with-keeping-order-in-text-string/m-p/1...

I could not manage to transfer the number in the string array into the numerical array.

 

Thanks in advance.

 

Mittani 

 

 

0 Kudos
Message 1 of 11
(4,133 Views)

If you don't want to convert to integers, why are you using that function? Make sure you have Context Help turned on and look at the other conversion functions. There is one that will do exactly what you want.

Message 2 of 11
(4,122 Views)
Solution
Accepted by topic author Mittani HD

Replace the decimal string to number conversion with the fractional equivalent Smiley Happy

 

StringNumConv.png


Regards,

Peter D

Message 3 of 11
(4,118 Views)

Thank you guys for your quick answers.

 

Dennis; that vi was my starting point. I turn on the help options usually.

 

This time I truned off the system decimal point in frac/exp string to number, and it works:)

 

 

Read real number from text file2.JPG

0 Kudos
Message 4 of 11
(4,106 Views)

Hi again,

I tried to take sub arrays from the array which contains fractional numbers.

Did not work and I got integers again.

Any suggestion?

 

 

Fractional number - chosing array subset.JPG

0 Kudos
Message 5 of 11
(4,093 Views)

Your indicator is of integer data type. Right-click a number in the array to change the representation to DBL.

Message 6 of 11
(4,091 Views)

Thank you:)

 

0 Kudos
Message 7 of 11
(4,084 Views)

Mittani HD wrote:

I tried to take sub arrays from the array which contains fractional numbers.

Did not work and I got integers again.



... or simply right-click the indicator and select "adapt to Source". 🙂

 

In any case your while loop is quite convoluted code. Since the number of iterations can be determined before the loop even starts, a FOR loop would be more correct.

Why do you think you need to get the array size with every iteration of the loop? The result never changes! This operation belongs before the loop. (of course the compiler might move it there behind the scenes as loop invariant code anyway ;))

What exactly is the loop supposed to do? Maybe you could just reshape into a 3D array and autoindex at the loop boundary to get the desired slices. Can you attach your code?

0 Kudos
Message 8 of 11
(4,072 Views)

Yes, Altenbach, array size should be outside of the loop, and for loop can be applied.

In fact it should be 3D array. The large 2D file is capacitance measurements which are taken every 20ms.

 

I think taking subarrays from the large array by a for loop is easier (?).

This subarray is multiplied by a sensitivity matrix to create a 32x32 image.

 This is the whole story.

 

So far I could not create a meaningful image.

Working on it:)

Download All
0 Kudos
Message 9 of 11
(4,057 Views)

Mittani HD wrote:

This subarray is multiplied by a sensitivity matrix to create a 32x32 image.

 This is the whole story.

 

So far I could not create a meaningful image.

Working on it:)


This cannot be the whole story. Currently you have 11x11 subarrays and I don't quite understand how this should translate into a 32x32 image after multiplication, especially since your sensitivity matrix is 66x812 elements????

 

Please explain what you mean by "image". Currently we a dealing with arrays, right. You could send the subarrays to an intensity graph to display as an image, but it is not clear if that's what you want.

 

Here is a quick draft how you could reshape to a 3D array, then play back the slices in a FOR loop. Right now I simply multiply with the oversized sensitivity matrix, but I doubt that's the right way.

 

(Regarding your program: Please get rid of the sequence structure and local variable. None are needed. The sequence structure just breaks dataflow and make the program hard to read and debug. The local variable causes additional copies of the array data in memory and there is absolutely no need for it. This is not text based code. The data lives in the wire, not in controls or indicators. After debugging, you could even delete the string indicator and the first array indicator, because they are not really needed.)

 

0 Kudos
Message 10 of 11
(4,046 Views)