Lavag Posted May 7, 2010 Report Share Posted May 7, 2010 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 Quote Link to comment
jcarmody Posted May 8, 2010 Report Share Posted May 8, 2010 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. Quote Link to comment
Shaun Hayward Posted May 9, 2010 Report Share Posted May 9, 2010 (edited) There's also a really handy function lurking in the comparison palette called "In Range and Coerce" which could certainly help you out a little bit: Shaun Edited May 9, 2010 by Shaun Hayward Quote Link to comment
Minh Pham Posted May 10, 2010 Report Share Posted May 10, 2010 Another option is to use case structure as shown: Another option is to use case structure as shown: what happened to my attached img? Quote Link to comment
Rolf Kalbermatter Posted May 10, 2010 Report Share Posted May 10, 2010 what happened to my attached img? I noticed this happening to all image attachments on LAVA lately. Must be a misconfiguration on the IP-Board software and I guess someone should alert Micheal about this. Quote Link to comment
asbo Posted May 10, 2010 Report Share Posted May 10, 2010 I noticed this happening to all image attachments on LAVA lately. Must be a misconfiguration on the IP-Board software and I guess someone should alert Micheal about this. I already made a post about this in the site/support sub-forum. Quote Link to comment
francis321 Posted May 12, 2010 Report Share Posted May 12, 2010 Hi It would be much easier to use the range 0-9, 10-19, 2029... But here a solution for your range( look at the picture).Quotient and remainder function. You do not need the for loop if you just dealwith one value at the time. Francis Quote Link to comment
torekp Posted May 14, 2010 Report Share Posted May 14, 2010 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). Quote Link to comment
francis321 Posted May 15, 2010 Report Share Posted May 15, 2010 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 Quote Link to comment
francis321 Posted May 15, 2010 Report Share Posted May 15, 2010 You were right Torekp. Your solution is much more simple! +1 Francis Quote Link to comment
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.