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: 

Divide an array

Hello,

I have an array of n elements, that are integers, and I'd like to split it in two arrays, one for the positive numbers, and another for the negative ones.
For example, the original array is:
-3 2 4 -1 5 5 6 -2 -1 2
and I want to split in two array like this
-3 -1 -2 -1
2 4 5 5 6 2
How can I do it?

Thanks,

Miquel Àngel Amer

Note: I enclose a VI file
0 Kudos
Message 1 of 3
(2,421 Views)
Your basic approach is correct, and here's a quick modification to your VI. What you should keep in mind is that:
1. You should initialize the shift register with the same kind of data you want to get from it, in this case - a 1D integer array.
2. When you have a tunnel coming out of a case structure, you need to wire data into it for every case. That means that when the array is unchanged, you need to wire the unchanged array into the tunnel.

___________________
Try to take over the world!
0 Kudos
Message 2 of 3
(2,416 Views)
There is a shipping example that does exactly what you're attempting to do. It's called Separate Array Values. It can be found by either going to the search tab in the Example Finder and using Array as the keywor, or from the Browse tab and selecting Fundamentals>Arrays and Clusters.
0 Kudos
Message 3 of 3
(2,405 Views)