Jump to content

Range


Recommended Posts

Hello guys,

First of all, I am glad to be here. I am a beginner at LabView (2009).

Second, I was suggested this site by a friend of mine in case I need help with LabView.

Third, I need HELP! hehe

Ok so I want to create range of number associated with another number.

i.e. Numbers 1-10 should be assigned value "1"

Number 11-20 should be assigned value "2"

and so on.

I want to compare my number with the range if it falls into the range, I want to assign the value assigned to that range.

i.e. # I have is 15 and I want to compare it with each range. Since 15 falls in between 11-20, I want to assign it # 2.

I am not looking for answer or code. All I want is an idea in the right direction. i.e., what types of things I should consider for creating different ranges and assigning them with numbers.

Thanks

Link to comment

Hello guys,

First of all, I am glad to be here. I am a beginner at LabView (2009).

Second, I was suggested this site by a friend of mine in case I need help with LabView.

Third, I need HELP! hehe

Ok so I want to create range of number associated with another number.

i.e. Numbers 1-10 should be assigned value "1"

Number 11-20 should be assigned value "2"

and so on.

I want to compare my number with the range if it falls into the range, I want to assign the value assigned to that range.

i.e. # I have is 15 and I want to compare it with each range. Since 15 falls in between 11-20, I want to assign it # 2.

I am not looking for answer or code. All I want is an idea in the right direction. i.e., what types of things I should consider for creating different ranges and assigning them with numbers.

Thanks

First of all, welcome.

Second, you've come to the right place.

Third, think about what you get if you divide the input number by the size of the range.  For your example, divide 15 by 10 and consider the result.  Try a few other numbers and you'll see what I'm getting at.

(hint: Quotient & Remainder)  Highlight the text before this line for a dead giveaway...

Good luck.  :) 

Link to comment

Francis has the best solution for ranges that are perfectly equal, and Shaun has a good one for ranges that are arbitrary (e.g., 1 to 6, 7 to 20, 21 to 22, ...). But for arbitrary ranges - a look-up table - I use the array thresholding function. Input the upper boundaries as the array input, and your test value as the scalar input. Round the fractional index down, and that gives you your category number (0-based - you can then add one if you like 1-based notation).

Link to comment

For arbitrary ranges you can use this (picture). The problem is if the value is out of range, the VI will never stop so you can add a manual boolean stop in the wile loop with a OR function.

Or just use a big value for the last range so you are sure it will always be in range.

Francis

post-17515-127388353204_thumb.jpg

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.