06-25-2021 04:49 PM - edited 06-25-2021 04:54 PM
Hi All,
This is a two part question. Been wracking my brain for ages with this and came up with a couple of ideas that have came as close as I can get to the expected output.
1) Is there a possible way of changing how Reshape Array places the n+1 element?
Normally, as an example, 1D to 2D Reshape Array gives:
1 2 3 4 5 6 7 8 -> 1 2 3 4 instead of -> 1 3 5 7
5 6 7 8 2 4 6 8
2) Is there a good way of removing zeros from a 2D array?
An example is attached with an attempt at a solution and expected outcome.
Solved! Go to Solution.
06-25-2021 06:14 PM
@SDuffyLV wrote:
Hi All,
This is a two part question. Been wracking my brain for ages with this and came up with a couple of ideas that have came as close as I can get to the expected output.
1) Is there a possible way of changing how Reshape Array places the n+1 element?
Normally, as an example, 1D to 2D Reshape Array gives:
1 2 3 4 5 6 7 8 -> 1 2 3 4 instead of -> 1 3 5 7
5 6 7 8 2 4 6 8
2) Is there a good way of removing zeros from a 2D array?
An example is attached with an attempt at a solution and expected outcome.
1) Nom the function won't do that. But you could code it:
2) I don't understand the concept of removing an element from a 2D array/
06-25-2021 06:30 PM - edited 06-25-2021 06:33 PM
Sometimes you simply need to occasionally transpose and correctly connect the reshape sizes.... 😄
(Still it all seems a bit hacky: Are we assuming that the arrays cannot have negative values? Why are things orange if we have all integers? Why is the input a 2D instead of a 1D array? Why sort if things are already sorted? Is the size guaranteed to be divisible by four? etc.)
What exactly is the purpose of all this? Where does the data come from?
06-25-2021 06:49 PM
Also if you remove the zeroes first, the code gets a bit simpler (no loop pyramids, etc.):
As I already said, it really depends on what we can expect from the data. Why are there zeroes in the first place?
06-26-2021 11:50 AM
Hi Altenbach,
Thanks for the reply.
Attached is a copy of a more in-depth look into the issue. I've answered a few questions below if the attached vi and txt document doesn't seem clear compared to the original.
06-26-2021 12:59 PM - edited 06-26-2021 01:07 PM
Your "expected" output contains stale default data, completely unrelated to the current input.
Can you explain the arrangement of the data in the text file. What's the significance of the rows and columns? So all you want is to keep the positive values, right?
Doing a reshape on a 2D array will keep the data in flat memory order and just redefine row sizes (and pad and trim as needed). Since your lines end up in an extra tab character, you get a fifth column of zeroes that will get intermixed after reshaping. Does not seem reasonable at all! Maybe you want the subset of the first four column instead. (A subset is very different from reshaping!!!)
Your file contains 278 positive values, which is not divisible by four. How should they be arranged?
06-26-2021 01:53 PM
@SDuffyLV wrote:
Did you mean to say 2D array?
06-26-2021 02:44 PM - edited 06-26-2021 02:46 PM
Apologies! Forgot to set the expected arrays as default.
Your file contains 278 positive values, which is not divisible by four. How should they be arranged?
06-26-2021 03:34 PM
If you randomly remove rows, the time information is lost. do you need to keep that information?
What should happen if for any give row only some elements are positive?
06-26-2021 03:53 PM - edited 06-26-2021 03:54 PM
If you randomly remove rows, the time information is lost. do you need to keep that information?
What should happen if for any give row only some elements are positive?
Simply, I just don't know how to shift the positive values to the top of the array and delete any zeros at the bottom. It doesn't matter what order the rows are in in each column, that's why one of the ideas was to Sort each column but then removing the zeros is the issue. If I just took the mean, it would include the zeros.