Raymno Posted April 17, 2013 Report Share Posted April 17, 2013 I need to search a vector of integers for a non-zero number. Perform an action based on location in the vector using the value and then search the next non-zero value. Is there a simple way to search the vector for the non-zero number? Link to comment Share on other sites More sharing options...
linxchas Posted April 18, 2013 Report Share Posted April 18, 2013 here is an example to find address of 1sr non-zero integer in the vector MI100 [100] Setting MB 0 will return result into MI97 Link to comment Share on other sites More sharing options...
Alexander Posted April 18, 2013 Report Share Posted April 18, 2013 There is no quick way to search for a non-zero number using the vector tools. It is possible to search for a value within a vector which will return the location, but what you are searching for needs to be defined. You could use the comparison function block, not equal, and when the value is a non-zero value it could perform a desired action based upon that value. This would need to be defined for each operand within the vector and would best be suited for a small vector size. If you are working with a large vector you could use Vector Compare using Offset, which you can compare to a constant vector of length 1 which has a value of zero. Each time you compare, increment the offset. If not 0, store the value and use it to perform an action. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now