11-17-2009 08:05 AM
Hi!
I'm just a beginner in Labview, I would appreciate every advice.
I have a 1D array, which I want to segment and put the segments in a 2D array as rows. What I want to do later is to separate the number sequences in rows in a 2D array without zeros. I tried to solve it by recursion, with not much success. My subVI works, I have problem with the other one.
For example I have the following input array: 0 2 1 3 0 0 4 5 0
Then I need the following 2D array:
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
2 1 3 0 ...
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
4 5 0 0 ...
Later I will delete the rows which contains only zeros.
Thank you for the help!
Greetings: Steven
Solved! Go to Solution.
11-17-2009 08:20 AM - edited 11-17-2009 08:21 AM
Hi Steven,
is there a rule behind your 1d data to 2d data conversion?
How do you come from
"0 2 1 3 0 0 4 5 0"
to
"
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
2 1 3 0 ...
0 0 0 0 ...
0 0 0 0 ...
0 0 0 0 ...
4 5 0 0 ...
"
What is the rule to split the 1d array? What is the rule to insert rows with just zeros? What is the rule to omit the zeros from 1d array?
What is the final size of your 2d array (how many columns do you want/need)?
So much questions from your description...
11-17-2009 09:59 AM
Well, at the very end I need a 2D array that contains only the numbers excluding the zeros. The number sequence after a zero need to be in the next row in the 2D array. Here's another example, maybe a bit clearer than the previous:
The input array is 0 3 2 4 0 0 0 1 6 0 5 9 8 0
Then I need a 2D array that is:
3 2 4
1 6 0
5 9 8
This will be a subVI in a bird song recognition project. This VI will get an input signal and I want to seperate the syllables from it so I can store them in a database. The input signal will have around 30,000 samples. The 2D output array will have no more than 1-2000 column.
11-17-2009 10:24 AM
Well, your second row has a zero... 😉
I guess you want a new row for each set of "nonzeroes", but padded with zeroes if the set is too short. Do you have always exactly three columns in the output or could there be more (e.g. if there are 10 consecutive nonzeroes)?
11-17-2009 10:35 AM
11-17-2009 10:55 AM - edited 11-17-2009 10:58 AM
11-17-2009 11:13 AM - edited 11-17-2009 11:13 AM
gisti87 wrote:
Yes, there can be more columns, and my numbers are not only single digit integers, they are floating point numbers.
Do you know the number of columns beforehand or do we need to find the largest set on nonzero numbers.
Comparing floating point with an integer (zero) can be tricky. Are the zeroes "real and exact zeroes" or can they be values very close to zero? (e.g. -3e-88).
Can you include a real dataset?
11-17-2009 11:21 AM
I don't know how many column will be needed, it's always changing.
The zeroes are exact zeroes (very small values from the signal is converted to zeroes previously).
I will get home in a couple of hours and I can send you a real dataset.
Thanks for the replies! 🙂
11-17-2009 12:51 PM
gisti87 wrote:I don't know how many column will be needed, it's always changing.
You may not know how many columns are needed but you should know on which bases we end row n and start row n+1 🙂
Is it "all numbers between 2 zero's build up one row" or is it something else?
gisti87 wrote:
The zeroes are exact zeroes (very small values from the signal is converted to zeroes previously).
Like altenbach said, a zero for you eyes may not be a zero for the computer.
11-17-2009 04:46 PM