LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

deleting data from array using case structure

As seen in the attached file, I have a formula node within a for loop. I use the formula node as a case structure, since it utilizes less space and is easier to read than graphical programming.

The problem that I am having is with the outputs A1 and B1. If the 'if' statement for these two is false, it outputs '0'. I don't want these '0' values within the array I am building - just the non-zero values. I had to initialize their values in the first 2 lines because they were outputing erroneous values.

Could I use an 'else' statement within this last 'if' and dump the values into a waste array? How do I incorporate this? Or could I query the original array (containing zeros and non-zeros) to return all non-zero
values?

thanks for any assistance.

Philip
0 Kudos
Message 1 of 4
(2,893 Views)
If you're using auto-index to create the output arrays, you add an element to the array on every loop. If you want to selectively add elements, don't auto-index. Use Build Array or Replace Array Subset in a case.
I've got to want you: you're just asking for trouble looking for help on a LabView forum and saying you use a formula node rather than a case because it's "easier to read than graphical programming". Such heresy! (Just kidding).
0 Kudos
Message 2 of 4
(2,893 Views)
I had tried the build array within a case but it appeared that every time a new data value entered its respective case, it wrote over the previous point. Attached is an example of the program. I'm still stumped.

I guess I should have said, "easier to write" (going to get flamed again!). I couldn't figure out how to write the case structure using G. The syntax of the 'and' comparisons didn't work. However, I think I would be having the same problems even if it were written in G instead of the C-based code.

Any suggestions? Thanks for the help.

Philip
0 Kudos
Message 3 of 4
(2,893 Views)
Look at the shipping example called Separate Array Values. It shows the correct way to do it. What you're missing is the shift register. The way you're doing it, you create a new array in each case statement instead of appending a new value to the previous array. The example also shows how to use the auto-indexing feature of for loops. No need to specify a number to the N terminal. And a word of warning about making comparisons with real numbers. Because of the imprecission of computers and the conversion between binary and floats, what you think is a zero might not be exactly zero.
0 Kudos
Message 4 of 4
(2,893 Views)