07-17-2013 09:51 PM
I have two 1d arrays that look like so:
There is always a zero in one of the arrays, but never both. Is there any way I can combine just the nonzero values into a single 1d array? Thanks for the help.
Solved! Go to Solution.
07-17-2013 10:16 PM
Concatenate the arrays. Then repetitively search the new 1-D array for zero values and delete them from the array.
07-17-2013 10:51 PM
I tried connecting each to the build array function and checking concatenate. That just combined two ten digit arrays into a 20 digit array containing a bunch of zeros.
07-17-2013 10:52 PM
Yes. And did you read my second sentence?
07-17-2013 11:18 PM
Oops sorry didn't notice it. Is there any way to tell the program to delete the zeros automatically and shift the remaining data up? When completed my program will have to deal with very large arrays.
07-17-2013 11:20 PM
No there isn't an "automatic" way.
An alternative is to delete the zeroes from the array before concatenating them together.
07-18-2013 06:46 AM
Try using a select function if the value is zero pass the default value or use build array and add the new value to the array.
07-18-2013 07:22 AM
As RavensFan Explained, first you need to concatenate the arrays and then search for zeros and delete them from array.
Attached below is the snippet, Check if this codew works for you.
07-18-2013 07:35 AM - edited 07-18-2013 07:39 AM
This ought to do it:
(See attached)
No need to size the second array since it is the same size as the first array (if I understand you correctly).
I don't know if it's the most efficient, but it's at least a small diagram.
(This may be your first suggestion in your post, gnshmrthy.)
Cameron
07-18-2013 08:03 AM
@chazzchuzz wrote:
I have two 1d arrays that look like so:
There is always a zero in one of the arrays, but never both. Is there any way I can combine just the nonzero values into a single 1d array? Thanks for the help.
I may oversimplify things a bit but if the arrays are always as shown (same numbers of items and always one and only one of the corresponding element zero) why don't you just add them?
Ben64