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? Quote 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 Quote 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.