LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Data

Solved!
Go to solution

I have an initialized 10,000 1D array with values -1. After replacing some values with collected data, I loop through the array, removing places where -1 still exists. However, it converts my data into integers where it initially had 2 decimal places. Any way around this?

0 Kudos
Message 1 of 8
(2,225 Views)

The selection terminal of a case structure defaults as a numeric input to I32, that's why the output of this terminal is an integer value.

Use another tunnel through the case structure border, then the value will remain double.

Greets, Dave
0 Kudos
Message 2 of 8
(2,209 Views)

@pvally wrote:

However, it converts my data into integers where it initially had 2 decimal places. Any way around this?


That is because a case structure cannot accept a floating point value.  It converts it to an integer first.  From what I am currently seeing, it looks like you should be using I32 for everything anyways.  But I am also VERY confused about what the code you shared is trying to do.  Could you share some more about what your code is supposed to be doing?  Maybe a little more context (code before and after the snippet) would help as well.


GCentral
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 8
(2,201 Views)

Can you demonstrate what you mean in this test VI.

0 Kudos
Message 4 of 8
(2,196 Views)

An array is leading into the for loop; it contains decimal values (ex: [298.17, 298.85, ... , -1, -1 ...]). It then returns an array containing [298, 299, ... ], removing the -1 places. 

0 Kudos
Message 5 of 8
(2,194 Views)

If using the case structure method to delete elements from the array only works for integers, can you recommend another way I delete the extra values from the array while maintaining the decimal places?

0 Kudos
Message 6 of 8
(2,173 Views)
Solution
Accepted by topic author pvally

Hi pvally,

 

you really should take the Training resources offered in the header of the LabVIEW board!

 

check.png

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 8
(2,129 Views)
Solution
Accepted by topic author pvally

@pvally wrote:

If using the case structure method to delete elements from the array only works for integers, can you recommend another way I delete the extra values from the array while maintaining the decimal places?


The problem was not with removing the values. The problem was that you were replacing values in your array with integer values. As noted previously based on the limited code shown in the picture it is possible that by using the actual array index value your code would probably work. 

 

I've attached a quick vi with an alternative method. The FOR loop on the right should do what you want. It takes an array that contains values of -1 or numbers greater than or equal to 0 and removes all of the values that are -1. If you have negative numbers then you need an entirely different approach.

 

Edited to add: Looks like GerdW already supplied the same solution.

0 Kudos
Message 8 of 8
(2,127 Views)