LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Arrays greater than 0 and taking only the elements that doesn't contain that

Hi, I have 6 arrays.
X-Axis, Y-Axis, PressRef, TempRef, PV, and VecorPress.
I have created a spreadsheet for them using txt
When I use colum 1 (X-Axis) Vs. column 2 (y-axis) to plot in an XY graph in excel, I want to delete all ELEMENTS that have the value ZERO on my X-axis.
Meaning that all the elements of X-axis that are 0's.

For example..

I have X,Y,Z
130     15   16
130     15   17
0         16   17
131     16   17

When I have it in my text. I only want to see this
130     15   16
130     15   17
131     16   17

I have a diagram picture of what i currently have and then i have a txt file that i currntly have. can someone help me?
thank you

Best regards,
Krispiekream
Download All
0 Kudos
Message 1 of 21
(4,499 Views)
Too many local variables. I suspect that if you look at your code you will be able to replace all those local variables with just wires.

It seems that you want to filter what gets written to file. You need to index through the array of values and only write out to file when the X value is zero. You can do this in 2 ways:
  • Create a new 2D array that is your filtered array, and then write this out using the Write to Spreadsheet File function. The brute force approach is to use a Build Array inside the loop to add a row to the 2D array if the value of X is not zero. A more elegant approach is to pre-allocate the size of the 2D array by determining how many zero values you have. Then you'll know how many rows the new 2D array will be.
  • Iterate through the array and write out to file line by line. In this case you would not write out a line if the value of X is zero.
The first method is the faster of the two, but requires more memory since you have to create a new, albeit temporary, 2D array. Note that if you use the Build Array approach there will be memory thrashing as LabVIEW needs to allocate more memory as the new 2D array grows. The second method is inherently slow since you are performing a file write operation for each line. I would suggest trying the first method.
0 Kudos
Message 2 of 21
(4,461 Views)
If you can use the openg array library then it's fairly easy (there's probably a faster way than this if needed).




Message Edited by Matt W on 11-05-2007 04:36 PM

Message Edited by Matt W on 11-05-2007 04:37 PM
0 Kudos
Message 3 of 21
(4,449 Views)
Hi Matt, do you have the Vi files for that?
I don't know what to look for in the array library

Best regards,
Krispiekream
0 Kudos
Message 4 of 21
(4,441 Views)

Yeah, sorry, I think I can replace those local variables with just wires. Sorry, the guy who taught me uses a lot of local variable and I gotten used to bad habits.
smercurio_fc, I don't know how to create a 2d array. sorry, but do you have any visual pictures i can look at? thanks..AGAIN!
Best regards,
Krispiekream
0 Kudos
Message 5 of 21
(4,438 Views)
The OpenG functions can be found from the OpenG site. They save you the trouble of having the code some stuff up yourself.

The "code it yourself approach" using a temporary 2D array looks like this:



Note: As I said, there will be some memory thrashing as LabVIEW allocates memory for the growing 2D array. The alternate method I described would use "Initialize Array" to create a 2D array and then use Replace Subset to "insert" the rows into the 2D array. I will leave it as a learning exercise for you to code that up.Smiley Wink

Message Edited by smercurio_fc on 11-05-2007 05:15 PM
0 Kudos
Message 6 of 21
(4,429 Views)
The openg library can be installed with vipm (there's a free comunity version), if you don't already have it, It has a lot of other useful libraries.

0 Kudos
Message 7 of 21
(4,425 Views)
i tried installing the openg on my labview and it said that it only support 8.2 and higher.
i have 8.0

Best regards,
Krispiekream
0 Kudos
Message 8 of 21
(4,420 Views)


Be careful with this approach.  Any x value less than 0.5 will be dropped in this solution.  It looks like it won't be a problem for you, as you have a measurement period of >1s.  But, if you pick up your rate, you could lose some good data points.

Why do you even have values where x=0?
0 Kudos
Message 9 of 21
(4,412 Views)
the previous programmer set the 0 to be the errors. i dont think there are points that are 0.5 in the txt file
Best regards,
Krispiekream
0 Kudos
Message 10 of 21
(4,399 Views)