11-13-2013 08:07 AM
Hello...please for advice.
I have an array of:
0
0
0
1
2
3
4
5
0
0
0
0
and i wanna delete just first three rows of zero and count how many rows i delete it. This first "zero" values are each time different. Sometimes i have 3 "zero" values another time i have 20 "zero" values.
Last "zero" values i wanna keep like they are.
Many many thanks
11-13-2013 09:36 AM
That "zero" value is something constant? Known during development?Not a floating number?
If so, you can use a conditional for loop to find the first "non-zero" element. The iterator of that for loop is the number of elements you want to delete from the array, so the length.
Using this approach, you should get a working solution. There might be better performing approaches out there......
Norbert
11-13-2013 10:33 AM - edited 11-13-2013 10:33 AM
Just to show what Norbert was saying. I used the Array Subset with the index wired to the i of the FOR loop. The length defaults to "rest", so everything starting with the first non-zero on will be kept.
11-13-2013 03:33 PM
Question, are the zeros added to the array because of how the program is written or are they actual data that you want to ignore? Basically, I asking if you are inserting the zeros into the array when you shouldn't be.
11-13-2013 07:16 PM - edited 11-13-2013 07:17 PM
Another way, without a FOR loop. Finds the first nonzero element and deletes everything up to that point.
11-14-2013 12:52 AM
Hello,
the zeros are actual data wich i want to ignore.
tnx
11-14-2013 01:09 AM - edited 11-14-2013 01:10 AM
@Zwired1 wrote:
Another way, without a FOR loop. Finds the first nonzero element and deletes everything up to that point.
This will only work if the first nonzero element is close to 1. If the first nonzero element is e.g. 10000, threshold array used in this manner will give the index of the last zero element.
Here's another alternative.
11-14-2013 01:23 AM - edited 11-14-2013 01:28 AM
Ah, right you are.
11-15-2013 02:06 AM
Thanx for all solutions. Tnx