Seraph Posted August 15, 2009 Report Share Posted August 15, 2009 Hi, again gurus, there is a simple exercise but I can not get the result I wanted, it is much like the dice problem, that is: with 10 possible values, generates a set of random numbers(the number of the random numbers is specified via input, say 100), and counts how many times each of the 10 values is hit. Of course we need an array to store the hit times for each of the 10 values, maybe, if possible, we need a 2-D array to make a simple table such that we can see which number was hit how many times. I've just been able to get the number of hit for each of the 10 values, but I don't know how to send them to array and display them in front panel as a 10-elment array. I've used the Creat Array function, but the result is not a 10-element array, but a 100-element one, and I have no idea about how to make the 2-D array mentioned above. Can any guru help me? thanks a lot! BR//Seraph Quote Link to comment
jgcode Posted August 15, 2009 Report Share Posted August 15, 2009 (edited) that is: with 10 possible values, generates a set of random numbers(the number of the random numbers is specified via input, say 100), and counts how many times each of the 10 values is hit. If I read the problem correctly - this may work? Edited August 15, 2009 by jgcode Quote Link to comment
Seraph Posted August 15, 2009 Author Report Share Posted August 15, 2009 Thank you very much, it is just what I mean. but I wonder why my solution doesn't work, the output is always the number of the hits for the last random number, the other hits are 0. As below: Sorry I don't know how to paste the block diagram here so I just paste two image file here, hope they can be helpful. I did see the values in the feedback nodes are counted correctly by runing the vi in highlight mode, but why there is only the number in active case branch is displayed while the other values are 0? Thanks a lot. Quote Link to comment
jgcode Posted August 15, 2009 Report Share Posted August 15, 2009 (edited) Thank you very much, it is just what I mean. but I wonder why my solution doesn't work, the output is always the number of the hits for the last random number, the other hits are 0. As below: The output of each numeric is always going to be the default value of a double (DBL) - which is zero, as you have use default if unwired selected on the output tunnel of each one on case structure. You will only return the correct number for the case that iterates last in the for loop. Edited August 15, 2009 by jgcode Quote Link to comment
Seraph Posted August 15, 2009 Author Report Share Posted August 15, 2009 Haha, I got it, we have to connect all wires in the case structure, rather than left them as default. From this point of view, the LabVIEW case structure is much less convenient to use than the other programming languages, image if we get more cases, we'll have to add more wires. Of course this is only an opinion from a novice, LabVIEW always has much better ways to solve problems. Anyway, thanks a lot to jgcode! Quote Link to comment
jcarmody Posted August 15, 2009 Report Share Posted August 15, 2009 From this point of view, the LabVIEW case structure is much less convenient to use than the other programming languages, image if we get more cases, we'll have to add more wires. Them's fightin' words! You can link tunnels so they're automatically wired when you add new cases. Right-click on an output tunnel and select Linked Input Tunnel and then Create or Create & Wire Unwired Cases. Notice the new glyph on the tunnel. Picture made with the Code Capture Tool. v/r Jim Quote Link to comment
jgcode Posted August 15, 2009 Report Share Posted August 15, 2009 (edited) You can link tunnels so they're automatically wired when you add new cases. Right-click on an output tunnel and select Linked Input Tunnel and then Create or Create & Wire Unwired Cases. Its worth a mention that, that feature is only available in LV8.6+ Jcarmody is right - If you want to update values on a case by case basis, then pass a single cluster via a Shift Register (or feedback node) and bundle the changed value per case into the cluster. Wiring all those values out through the structure as you have, is just plain ugly and is why you think you will need to add more wires when adding more cases - this is incorrect. the LabVIEW case structure is much less convenient to use than the other programming languages, image if we get more cases, we'll have to add more wires. LabVIEW used correctly is very elegant. Edited August 15, 2009 by jgcode Quote Link to comment
patleb Posted June 13, 2014 Report Share Posted June 13, 2014 While were on the linked input tunnel subject, Why is the linked input tunnel option for the tunnel I've created on the output side of a case structure greyed out? Quote Link to comment
hooovahh Posted June 16, 2014 Report Share Posted June 16, 2014 While were on the linked input tunnel subject, Why is the linked input tunnel option for the tunnel I've created on the output side of a case structure greyed out? If you only have an output of the case structure, and no input to link it to, the option will be greyed out. Not sure what other situations will cause that. Quote Link to comment
patleb Posted June 24, 2014 Report Share Posted June 24, 2014 I figured it out... used to programing in 2009 and it does not have this option. 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.