Clearing frequency array

Could anyone point me in the right direction for clearing a frequency array?

I have a dice simulation program that rolls a user defined number of times. It stores the random rolls in a frequency array. Then builds a histogram of the random rolls. I need to clear the array, so that the program can be run, print report, cleared, run again, etc...
Here is how I set the frequency array...
int die1, die2, valueOfRoll;
Random numberGenerator = new Random();
for (int i = 0; i < numRolls; i++)
die1 = numberGenerator.nextInt(6) + 1;
die2 = numberGenerator.nextInt(6) + 1;
valueOfRoll = die1 + die2;
frequency[valueOfRoll-2]++;
Now I need to know how to clear it.

Similar Messages

  • Trying to clear an array inside a case structure

    Good morning all.  I am trying (unsuccessfully, obviously) to clear an array inside a case structure.  (See case structure at right side of vi, I colored it green to make it easy to find).  Here's (briefly) what I'm trying to do.  I have 6 test probes in the process.  All six probes are connected to the Alcatel Detector through a 6-solenoid manifold.  As I run the test, I want to sample 1/second, for let's say 3 minutes.  For the first 30 seconds, I want to pull a sample from from probe 1, so I turn on solenoid one and leave it open for 30 seconds.  Now all 30 values are tagged as having come from Probe 1, and they're stored in array 1.  I can now compute an average value for probe 1. Then I close solenoid 1 and open solenoid 2, saving the next 30 values to array 2.  (and so-on, until I have measured all 6 probes for 30 seconds each).  Then I wait a pre-determined amount of time and repeat the process.  Here's my problem.  I want to clear out each array as I begin the second iteration, so that I can easily compute the average of the last 30 values.  If I initialize the array by connecting a constant 0 to the shift register on the for loop insid ethe case structure, it does not work, nor does it work to place the 0 outide the overall for loop (the next for loop going out, NOT the OVERALL for loop).  I know my programming skills are still crude, but I'm putting everything into this.  Anyone have any suggestions? 
    Attachments:
    HCMF rev 1 25 Apr.vi ‏485 KB

    Altenbach, I definately understand your approach, and I like it much better than my own.  But I still have no luck making it work.   I get the same result as before (my original attempt).  Value 0 of the array simply changes each iteration, with nothing "saved".  Each new value simply overwrites the last value.  Can you take a look at my new vi, with changes, and see if you can find the error of my ways.  I am but a rookie Jedi in the vast reaches of LabVIEW Space, and you are no doubt a Jedi MASTER
    Attachments:
    HCMF rev 1 25 Apr pm.vi ‏374 KB

  • AS3 Best way to clear an array

    What is the best way to clear an array? (performance and resources)
    array.length = 0;
    array = [];
    array.splice(0);

    that's creating a new array which is extra work, and it's adding an array to the objects that flash will gc, and that's extra work.
    assigning the length to 0 is the most efficient way to clear an array.

  • Intermittent problem using "invoke node - reinitialization to default" command to clear an array

    I use the "reinitalization to default" invoke node to clear an array after sending the data to a file. The next time the vi is called the array should appear with all elements set at the default values. However occasionally the array will not be cleared and data from the previous time the vi was called is still in the arrary, or at least it appears that way since the same data for the previous time called appear in the file  when the new values are appended to the file. New data appears okay, only data points in the array which I dont update appear with the old values. And again it's an intermittent problem. I can fix the problem for a while anyway by shutting down labview and rerunning it.  Any ideas what's going on?
    Thank you.
    Chuck
    Solved!
    Go to Solution.

    A lot of this code should be done different, just for the reason that it is difficult to find such problems. I would suggest you browse examples about state machines to see some 'best practices'.
    But I guess I found the source of your error for now: I checked the control labled '1' which is used to build your appended array. Here I didn't find any initialization code or invoke node. Maybe that's it?
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Clearing an array without deleting it

    What would be the fastest way of clearing an array without
    deleting it? Could you set all values to null or undefined and it
    would work? For example, say I have an array of 4 numbers: 3, 4, 5,
    6. Now, for some reason I want to clear all the values and set only
    one value, so now I have an array of 1 number with a length of only
    1: 7. How can I do this without deleting the array? Remeber, I only
    want this array to have a length of one, not 4.

    u could try this one may be it should work for ur
    requirements.
    var myArray:Array = new Array(1, 3, 4, 5)
    myArray.length = 1;
    trace(myArray)

  • How to clear an array?

    I want to clear an one dimension and also 2-dimension numeric arrays.  Is there a single command that does it?
    Thanks
    Rafi

    HI,
    Here is an example of using the ArrayDimensions
    Locals.arrOneDim.Type.ArrayDimensions.SetBoundsByStrings("[0]","[0]" )Locals.arrTwoDim.Type.ArrayDimensions.SetBoundsByStrings("[0][0]","[0][0]" ) 
    There is a SetBounds which you can use a long array so its of the format
      Locals.arrTwoDim.Type.ArrayDimensions.SetBounds({0,0},{0,0})
    Regards
    Ray Farmer
    Message Edited by Ray Farmer on 11-11-2008 09:55 PM
    Regards
    Ray Farmer

  • How to quickly clear an array used in a shift register?

    Hello all,
    I'm sure this is a quick one, but I'm missing the concept.
    I have an array of boolean in a shift register. I have a case where I need to basically 'reset' the array rather than append to it....what is the best way to do this?
    Thank you,
    cayenne
    Solved!
    Go to Solution.

    stevem181 wrote:
    Of course, it is possible that my benchmark program is flawed.
    Yup, disable debugging and you will see that the inner FOR loop is folded in both cases and the time drops to about zero.
    Testing with debugging enabled is potentially unfair, because the reshaping will have more debugging code because there are more potential places to probe a wire, for example. All that said, I don't really know what's more efficient. That would require much more sophisticated testing. My point was just a reminder that there are always many ways to do things.
    (This is under LabVIEW 2012. Constant folding and dead code elimination of course differ between compiler versions)
    Granted, I typically don't use any of these two versions: I also omit the diagram constant, set the tunnel to "use default if unwired" and keep in unwired in the "clear" case. Less diagram clutter and quicker coding.
    Here's how it would look like.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Folding.png ‏13 KB
    UseDefault.png ‏3 KB

  • Clearing the array of type Serializable

    Hi all,
    In my process request of my controller i have the following code:
    String umxRegParams = pageContext.getParameter("UMXRegParams");
    Serializable parameters[] = {umxRegParams};
    basically I'm getting the parameter of UMXRegParams from the pagecontext and storing it into an array called parameters[].
    What i want to do is to be able to clear whatever is in parameters[] when press the apply button in process form request. Is this possible?
    Thanks

    when you creating new object parameter of Type of Serializable [] then it already empty.
    you can do also in this way
    Serializable parameter[] = null;
    Thanks

  • Trying to clear an array of clusters with image info from memory - overflowing!

    I am using a cluster with IMAQ interface name, session info, image array, and individual image and creating an array of that cluster. I try to clear the cluster by deleting the array elements, read an array of images, save them, and repeat the loop. Over time, though the arrays are tearing through all available RAM. I tried removing local variables (which I understand would save a copy of the entire array to memory every loop iteration) and had no luck - actually the code hangs now on the write function, where it thinks there is no image data. I didn't think I changed anything other than to direct wire where there had been local vars to pass information from one part of the sequence to the next. Help! (screenshots of code attached).
    Attachments:
    framegrab sequence 1.jpg ‏8 KB
    framegrab sequence 1a.jpg ‏47 KB
    framegrab sequence 2 - grab and save.jpg ‏149 KB

    Hi, Nasgul,
    Not sure where you have resources leak - from your screenshots its not clear.
    But one is clear - you may not understand that IMAQ Images in LabVIEW passed by references. So, if you want to create array of images, then for each element IMAQ Create should be called with different name, otherwise all elements referred to the same image. For example, if IMAQ Dispose will be called for the first elementh of the array, then other 9 images will be automatically invalid.
    Compare two code snippets below:
    Common recipe for solving troubles with resources - reduce your application step by step by isolating parts of the code with case structures until application will be stable. Then you will found part of code which caused memory leak. 
    best regards,
    Andrey.

  • Clear an array after test

    Hi all
    I've just been busy with a vi, and have worked out a way to test between two arrays, and output the missing numbers from the first array compared to the second. I take these numbers from two lists in separate text files. These lists are placed in arrays, and then compared against each other. The problem im dealing with is that after Labview has run once, it stores the values last collected, and places teh next ones on top of the previous, and therefore the arrays get bigger and bigger and bigger. I need the arrays to run once, clear, and then be able to run again giving new results. The difficulty is the text files will be changing all the time from an outside code, and the output array needs to keep up to date with the input arrays. This is my code so far.
    Thanks so much
    Jingles
    Solved!
    Go to Solution.
    Attachments:
    Testarrayfiles.vi ‏15 KB

    As Jeff already hinted, your code is very convoluted for such a simple taks and also thrashes the memory. Try to find an "in place" solution.
    Why is there a representation mismatch at the end? Since you are reading and keeping only the integer parts, it seems useless to carry out the entire thing with DBL types.
    LabVIEW Champion . Do more with less code and in less time .

  • How to clear byte array

    Hi, here are the codes
    byte[] buffer = new byte[1000];
    // use the buffer for something else
    then How can I clear the content of this buffer,
    so I can use it for TCP/IP datainstream again
    int result=in.read(buffer);
    Thank you very much.

    Hi, here are the codes
    byte[] buffer = new byte[1000];
    // use the buffer for something else
    then How can I clear the content of this buffer,
    so I can use it for TCP/IP datainstream again
    int result=in.read(buffer);
    Thank you very much. You shouldn't have to clear the buffer. The read() method returns the number of bytes read, so you know not to read past that point in the buffer.
    As an example, here is some code that reads from one stream and writes to another. Note that I use the 3 parameter version of write() to make sure I only use the part of the buffer that actually got filled by the last call to read(). In the following, os is an OutputStream and is is an InputStream.
                        byte[] buf = new byte[1024];
                        int count = 0;
                        while((count=is.read(buf))!=-1) {
                          os.write(buf, 0, count);
                        }

  • Clearing byte array field

    Hello all,
    I've encountered a problem in trying to reset fields in my applets which I just can't figure out, I'd appreciate some help with it.
    Basically I have a method in a base class for my applets which sets the fields in my card. This works fine, the problem I have is when I tried to alter this method so that if the command APDU received does not contain the data field(i.e. a Case 2 APDU, 5 bytes long), then the designated byte array is set to null. The code is shown below.
    // Method in applet
    public void setSurname(APDU apdu) {
    surname = setByteArrayVariable(apdu);
    // Method in applets' base class
    public byte[] setByteArrayVariable(APDU apdu) {
    byte[] apduBuffer = apdu.getBuffer();
    short len = apduBuffer[ISO7816.OFFSET_LC];
    byte[] arrayname = null;
    if(len != (short)0){
    arrayname = new byte[len];
    // copy buffer data into byte[]
    short bytesRead = apdu.setIncomingAndReceive();
    short Offset = (short)0;
    while (bytesRead > 0) {
    Util.arrayCopy(apduBuffer, ISO7816.OFFSET_CDATA, arrayname, Offset, bytesRead);
    Offset += bytesRead;
    bytesRead = apdu.receiveBytes(ISO7816.OFFSET_CDATA);
    return arrayname;
    What happens when I send the Case 2 APDU to the applet is that the CLA and INS bytes direct the apdu to the proper method to set the field and the byte array is set to null(success). At this point I expect the JCRE to return the sw 9000, however what actually happens is the applet throws the ISOException defined in the default case of the process method. Also I checked this method in the gemplus simulator and it works as expected, its only when I tried it in a GXP211_PK_IS card that the problem occurred, I've asked the Gemplus support about this but as yet have not heard anything in response. I cannot explain why this is happening, has anybody got any suggestions? Thanks,
    Tony

    The status word which is returned is 6D00(INS not supported), as this is what I throw in the process method when the switch doesn't match the INS byte with any of the cases. This is where my confusion comes from, if the method is called(through matching the CLA and INS bytes) how is it that after the method is completed(successfully, as the field is set to null) that the exception is thrown form the process method as if the method wasn't found? I have a workaround whereby instead of throwing the 6D00 I throw the ISO7816.SW_NO_ERROR in the default case of my process method, this can only be a temporary workaround though!!
    I'm guessing that you check for surname != null later on ? I do check this but only when I'm trying to retrieve the surname from the card, basically, if(surname == null)ISOException.throwIt(ISO7816.SW_FILE_NOT_FOUND);
    Doesn't sound like thats what you're getting at though??
    (Will sort out the memory allocation, cheers.)
    TIA for any help you can provide, leaving now for the day but hoping to hear from you tomorrow :)
    Tony

  • How to get a clear frequency representation of voice

    I am not sure what cause this problem. I saw professional recording their voice and get clear representation of overtones. You can see solid lines.
    But when I record my voice, the representation is blurry. They are not lines. The representation is basically useless.
    Is it caused by surrounding noise? Equipment? Or my voice?

    Hi Gary,
    In order to pull CDR information, you can perform the following steps:
    1.       Go to 'Cisco Unified Serviceability' of the Publisher and click on Go.
    2.       Select Tools -> CDR Analysis and Reporting.
    3.       Go to CDR -> Export CDR/CMR.
    4.       Select the From and To date. (Make sure you have 'CDR Records' option selected)
    5.       Click on Export to file.
    6.       Right Click on 'CDR Dump' and save it using Save Target as/Save link as.
    7.       If you want to retain the CDR file in the call manager, please 'uncheck' the Delete File option.
    Now the file would be saved on your system and you can open it in Microsoft
    Excel using the following steps to have it in a readable format.
    1.       Open Excel -> File -> Open -> Select the file saved -> click on open.
    2.       Use 'Delimited' -> Next
    3.       Select 'Tab' and 'Comma' as the Delimiters -> Click on Next.
    4.       Select Current data format as General -> Finish.
    Now, you should be able to view all the details in a Spreadsheet.
    Note that the time of the records under 'dateTimeOrigination' coloumn would be in Epoch Time. It is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601:
    1970-01-01T00:00:00Z).
    In order to convert it in human readable format, you can look for Epoch convertor that is easily available on the internet.
    You can also visit the following link to use a formula to convert the time into human readable format.
    http://www.blindhog.net/convert-epoch-time-in-excel/
    HTH,
    Jagpreet Singh Barmi

  • How to change the frequency of pulse train on the fly using an array of values?

    Hi all!
    First I want to thank U for the great job you are doing for this forum.
    Iam still busy trying to control a stepper motor, by sending pulses from my E-series 6024 to a compumotor s6- stepper Driver. I've managed to get it working. I desperately need to control the motor using the values from an array. I believe we can use two approaches for that:
    1st - I can get an array of the "numbers of pulses". Each element must run for 10 milliseconds. Using that we can calculate the array of frequencies to send the number of pulses within 10 milliseconds for each specific element. Could we use the arrays of "number of pulses" and frequencies in a "finite pulse train " and up
    date with each element every 10 millisecond?
    2nd - Or Could we use of the frequency array in a "continuous pulse train vi" and update it every 10 milliseconds?
    Please note that I must use the values as they are.
    Can someone please built a good example for me? Your help will be appreciated.
    Regards
    Chris
    Attachments:
    number_of_steps.txt ‏17 KB
    frequency.txt ‏15 KB

    Tiano,
    I will try to better explain the paragraph on LabVIEW. The original paragraph reads ...
    "While in a loop for continuous pulse train generation, make two calls to Counter Set Attribute.vi to set the values for "pulse spec 1" (constant 14) and "pulse spec 2" (constant 15). Following these calls you would make a call to Counter Control.vi with the control code set to "switch cycle" (constant 7). The attached LabVIEW programs demonstrate this flow."
    You can make two calls to Counter Set Attribute or you can make a call to Set Pulse Specs which, if you open this VI, you will see that it is just making two calls to Counter Set Attribute. What you are doing with the Counter Set Attribute VIs is setting two registers called "pulse s
    pec 1" and "pulse spec 2". These two registers are used to configure the frequency and duty cycle of your output frequency.
    The example program which is attached to this Knowledge Base demonstrates how to change the frequency of a continuous generation on the fly. Why continuous? Because changing the frequency of a finite train would be easy. When the train completes it's finite generation you would just change the frequency and run a finite train again. You would not care about the time delay due to reconfiguration of the counter.
    If you would like to change the frequency of the pulse train using a knob, this functionality will have to be added in the while loop. The while loop will be continuously checking for the new value of the knob and using the knob value to set the pulse specs.
    LabVIEW is a language, and as with learning all new languages (spoken or programatic) there is a lot of learning to be accomplished. The great thing is that LabVIEW is much easier than mo
    st languages and the learning curve should be much smaller. Don't fret, you'll be an expert before you know it. Especially since you're tackling a challenging first project.
    Regards,
    Justin Britten

  • How to clear two dimension array and content in JTextArea

    hi all....
    i have a problem to clear the counter in JTextArea..currently i design a program to store all the student details in two dimensian array...when i click "RESET"button..it will only reset the textarea..but can not clear the actual content inside the array..and when i click "Print Button" again..it's supposed nothing to display..but it displayed the thing which i previously entered......
    so i think i need to clear the array...i use append to insert the text...,for this i also can not reset...
    which the code is shown below :
    txtArea.append(msg1);
    the coding for reset area as below :
    txtArea.setText("")
    Anyone can help me?????
    thks...

    How are you trying to reset the array?, you can just creat a new array.
    Noah

Maybe you are looking for

  • How to pick a HDD ?

    Hi, I am looking for a hard disk for a 2005 Toshiba Satellite laptop which I bought in Singapore. Model : Satellite M50-P330Satellite M50-P330 Part number: PSM51L-001001 I checked http://www.toshibadirect.com but could not find the precise model numb

  • Mail has blue boxes with question marks

    I have a new MacBook Pro. In mail when I receive anything with images, I just see blue boxes with question marks. Yes, i have tried reloading Mail, I have tried clicking on and off from Display remote Images, I have checked all my preferences and it

  • Using your own router - out of warranty

    I'm having router problems - i know its an issue with the router, the number of devices connected and the fact that the router itself is quite old. I don't need to troubleshoot the router (which I've done with support). I was told I might need a repl

  • An error has occurred in the script on this page.

    When I start the computer, and get to the Windows page, before I open any other programs, I am getting this error message in a box: An error has occurred in the script on this page. Line:  1 Char: 1 Error:  Unable to open registry key             "HK

  • Adapting a 6230 car kit to a new n95 phone

    Hi Is it possible to get an adapter so i can upgrade my 6230 to a n95 and use it on my built in nokia car kit???