I'm having problems manipulating array data within a for loop, and extracting the required sub-arrays generated.

Hi,
I'm using labVIEW V5.1
I'm trying to generate 10 1D arrays, the first array is initialized to all zeroes, then I have set up a for loop which shifts the first element by 1, then a random number is placed into the first element position. I am using a shift register to feed back in the newly generated array into the start of the loop.
By the end of the each loop I want to be able to use the array generated in an algorithm outside the loop. However I only want the Nx1 array that has just been generated.
Unfortunately, I cannot figure out how to resize, reshape or index the output array to do this.
I would like the loop to
give me out a 1D array after each iteration.
Any help would be greatly appreciated.

I hope I've understood your problem.
First your vi was lacking of the sub-vi working as shift register, I've replaced it with the rotate function.
The indexing of your arrays create a 2D array whose rows are your 1D array.To pick only one of them you have to use the index array function and select which one you want.
To use your temporary data in another part of your application you should use a local variable of array2.
I did it in a separated while loop That I syncronized with the for loop using occurrence, in this way the while loop runs each time a new value is inserted in array2 (each loop of the for loop structure).
If you don't need this syncronization just get rid of occurrence functions.
I place a delay in the for loop to show what happens when running.
Hope it was helpful.
Alberto Locatelli
Attachments:
array_test_v3.vi ‏35 KB

Similar Messages

  • Is there any point in having an ORDER BY clause within a FOR LOOPs counter?

    DB Version:10.2.0.1.0
    I need to loop through empno's using a FOR loop. But is there any point in having an Order by clause within SQL as shown below. This only degrades the performance because of the unnecessary sorting by the ORDER BY clause. Right?
    begin
    FOR i IN (select empno from emp ORDER BY sal ASC) LOOP 
        curr_stat_id := i.empno +p_gennum;
    .

    First question you should ask to your self is
    "Do i need a FOR LOOP. Cant i do it in a straight SQL"
    If the answer is NO (Which is not in several cases) then the next question is.
    "What is my requirement"
    Having an order by in the Select is totally pertained to your requirement. If your requirement
    says you should loop through the employee based on there salary for lowest to highest then yes you
    need an order by.
    So more than performance point of view its requirement point of you. But if you are more concern about
    performance you will first ask to your self
    "Do i need a FOR LOOP. Cant i do it in a straight SQL"
    Thanks,
    Karthick.

  • I need to take elements from within 2 nested for loops and place them in an array at the specific row and column that I need.

    I have tried intializing an array and replacing elements by specifying a particular row, and column, but in the end I get an array with only one element replaced, and I suspect that it is because as the for loops are running through their iterations each time the array is re-initializing. I have a simple vi that I will post below, it is not the exact situation that I have but is a good place for me to get some understanding. I have the row and column indexes being driven by the inner and outer loop iterations, which gives me the pattern I need. I am using the inner iterations as array elements. How do I set this up so that it works and d
    oes keep re-initializing my array.
    Attachments:
    Untitled.vi ‏26 KB

    I have fixed a number of things in your vi.
    You were right in thinking that the array was continuously re-initialized. To avoid this, use a shift register (right-click the loop border), which will pass the updated array into the next iteration.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    your_vi.vi.zip ‏13 KB

  • Reading a csv file within a for loop

    Hi guys,
    Im trying to read a csv file within a for loop and the while loop only seems to be getting executed once rather than the number of times that is specified.
    for(int i=0; i<paramValues.length;i++)
    String StudentNo = paramValues4;
    out.println("StudentNo="+StudentNo);
    BufferedReader in = new BufferedReader( new InputStreamReader( conn2.getInputStream()));
    String readLine;     // stores a line from the file as a string//used to get rid of the first line which has course name
                                                      readLine = in.readLine();
                                                                     int NumberOfElementsInArray=16;
                                                           String[] data;
                                                                     data = new String[NumberOfElementsInArray];
                                                                     data[0]=> StudentNo
                                                                     data[1]=> Surname
                                                                     data[2]=> Firstname
                                                                     data[3]=> ExamNo
                                                                     data[4]=> YrOfStdy
                                                                     data[5]=> ProgOfStdy
                                                                     data[6]=> Fld1
                                                                     data[7]=> Fld2
                                                                     data[8]=> DegType
                                                                     data[9]=> EnrolStatus
                                                                     data[10]=> StaffAdvNo
                                                                     data[11]=> Tutor
                                                                     data[12]=> Fld3
                                                                     data[13]=> Fld4
                                                                     data[14]=> Fld5
                                                                     data[15]=> Pegged
                                                                     data[16]                                                            
                                                                     //out.println("<table border=\"1\">");
                                                                     int datanumber=0;
                                                                     while( (readLine = in.readLine()) != null )     
                                                                          out.println("ive entered the loop");                                                       
                                                                          StringTokenizer tokens = new StringTokenizer( readLine, ",", true);                    
                                                                          boolean prevTokenComma = true;
                                                                          boolean emptyValue = false;
                                                                          String aValue = null;
                                                                          datanumber=0;                                                                      
                                                                          while( tokens.hasMoreTokens() )          
                                                                               aValue = null;
                                                                               String token = tokens.nextToken();
                                                                               token=token.trim();
                                                                               //if the token does not equal to a comma
                                                                               if( !token.equals(",") )               
                                                                                    aValue = token;                    
                                                                                    prevTokenComma = false;                    
                                                                                    emptyValue = false;     
                                                                               else if( token.equals(",") && prevTokenComma )               
                                                                                    prevTokenComma = true;                    
                                                                                    emptyValue = true;               
                                                                               else //( token.equals(",") && !prevTokenComma )               
                                                                                    prevTokenComma = true;                    
                                                                                    emptyValue = false;
                                                                               if(emptyValue)
                                                                                    aValue = "";
                                                                               // Printing values
                                                                               if( aValue == null)
                                                                                    //do nothing
                                                                               else if (aValue.equals("") )
                                                                                    aValue="&nbsp";
                                                                                    data[datanumber]=aValue;
                                                                                    //out.println("datanumber="+datanumber);
                                                                                    //out.println("<td> aValue: "+aValue+"</td>");
                                                                                    datanumber++;
                                                                               else
                                                                                    data[datanumber]=aValue;
                                                                                    //out.println("<td> aValue: "+aValue+"</td>");
                                                                                    //out.println(datanumber);
                                                                                    datanumber++;                                                                                
                                                                          out.println("data[0]="+data[0]);
                                                                          //out.println("data[3]="+data[3]);
                                                                          //out.println("ExamNo="+ExamNo);
                                                                     }//end while
                                                                     in.close();
    }//end for loop
    When I print the variable student no at the beginning of the for loop it prints the different studentno's so the for loop is fine, but the while loop gets executed once. Does anyone know why????????/
    Thanks
    Tzaf

    PROBLEM SOLVED....
    Basically the following declarations have been done within the for loop....
    URL url2 = new URL ("http://localhost:8080/FYP/CSVFILES"+Year+"/"+WebCourse2+".csv");
                                                                     URLConnection conn2 = url2.openConnection();
                                                                     HttpURLConnection uc = (HttpURLConnection)conn2;
                                                                     uc.connect();
                                                                     try
                                                                          responseCode = uc.getResponseCode();
                                                                          out.println("Response code1: " + responseCode+"\n");
                                                                     catch(IOException e)
                                                                          responseCode = uc.getResponseCode();
                                                                          //out.println("Response code2: " + responseCode+"\n");
    thanks
    anyway
    tzaf

  • Having problem with storing data in array

    Hi,
    I'm having problem on storing data in array. My problem is that each time it loops, the array just keep overwrite instead save to the next index. Like at 0 the value is 123, and 1 is 234. But i having that all data capture all overwrite at 0 till the last data it still show at 0. How do i correct this problem?
    Solved!
    Go to Solution.

    How to use array to do comparison? Like Array 1 go thru array 2 to get data Loss out and build an array. Like Array 1 ,1000,1024,1048,etc before 1520 fall in between Array 2 range 1000-1500. So Freq 1000,1024,1048 etc will get Loss value as 1 and 1520 fall in between 1500-2000 will output Loss 2. and so on till the end of the list. How should do this? Need help on this.
    Array 1                                                Array 2
    Freq                                              ​     Freq   Loss
    1000                                              ​    1000      1
    1024                                              ​    1500      2
    1048                                              ​    2000      3
    1100                                              ​     :
    1200                                              ​     :
    :                                                 ​        18000
    1520
    18000

  • Truncating an array within a for loop

    I'm currently working with a program that builds an array of 3000*N real numbers, where N is a control that I specify. I want to pass this array into a for loop that runs N times, each time splitting the first 3000 numbers of the array. So, in other words I want the for loop to execute enough times such that the initial array will be completely divided into groups of 3000 when I'm finished. Later I'll be finding the maximum value of all of these subarrays and taking the average of those. What I tried first is to pass the array into the for loop, then truncate it at index = 3000, but the problem is that I can't hard code the loop to do this N times. Any advice or other methods you'd recommend for doing this?
    Thanks.
    Message Edited by Robtn on 03-05-2010 03:17 PM

    Mark--I don't think I can use that approach. Let me be more specific on what the problem is:
    Our "big program" is a giant while loop that constantly reads in voltage values from a DAQ assistant.
    It has two modes, the first of which I'm having a lot of trouble with. This mode uses a for loop (N = 3000) nested within the giant while loop.
    When the for loop activates, the DAQ assistant takes reads 300 samples for every iteration and takes the maximum of those 300 values. It then builds an array composed of all the maxima. After the for loop has executed 3000 times, a case structure activates, which then finds the maximum of the array of maxima.
    I want this (N=3000) for loop to execute an arbitrary number of times, a number that I will specify. Each of those times it should generate a completely seperate array of maxima. So, if I want the for loop to run 5 times, I want 5 different arrays.
    My approach for doing this was to change N=3000 to say N = 15000, then split up the resulting array 5 times. So, I need an entirely separate for loop that reads in this array of 15000 maxima on its own and splits it 5 ways. I think what you're suggesting is to use a for loop outside of the N=3000 loop, which is a good idea in theory, but experience has shown that this will not generate 5 separate arrays. It will actually concatenate each array into one, hence the problem we currently have.
    Yik--I won't have access to Labview over the weekend. Is it possible to take a screenshot and post it, or maybe a short description?
    Thank you for the responses.

  • How do I set a variable within a 'for' loop grid array

    I'm afraid I'm stuck again!
    The next stage in the animation that I'm working on,  is to set up a boolean, 'drilled = false', so that all instances of the attachMovie ('openCircle') have a boolean 'drilled = false' associated with them. Then when someone clicks on one of the instances of the attachMovie ('openCircle'), the boolean becomes 'drilled = true', but only for that instance that has been clicked.
    What I've done is to set the variable (boolean)(highlighted in bold below) within both 'for' loops within the grid array, but it just returns an undefined value. Do I need to setup a separate array? (see code below):-
    //set up grid for solid array
    var spacing:Number = 5.75;
    var cols:Number = 20; // number of columns in grid
    var rows:Number = 20; // number of rows in grid
    var leftMargin:Number = 154;
    var topMargin:Number = 169;
    var depth:Number = 100; // starting point for depth
    var drilled:Boolean;
    for (i=1; i<=rows; i++) {                                                                                                         
    for (j=1; j<=cols; j++) {                                                                                                                              
              drilled[rows,cols]=false;
                        trace(drilled);
              current = attachMovie("openCircle_mc", "openCircle_mc"+i+"_"+j, depth++);
              current._x = leftMargin + ((i-1) * (spacing + current._width));
              current._y = topMargin + ((j-1) * (spacing + current._height));
              current.row=i;
              current.col=j;
    //          current.oil = Math.floor(Math.random()*1.1);  // about 1/10 objects have oil=1, 9/10 oil=0
              //open circle initially invisible, visible on rollOver
              current._alpha = 0;
              current.onRelease=function(){
                        trace(this.row+" "+this.col);
       current.drilled = true;
              current.onRollOver = function() {
                                     this._alpha = 100;
              current.onRollOut = function() {
                                     this._alpha = 0;
    I'd be grateful for any help. Thanks.

    I'm sorry for asking this question again, but I really need to have the 'drilled' variable to be available at all times outside the openCircle_mc, so if I can set up the 'drilled' variable as an array that would be good. Below is the code that isn't working:
    /*  set all values of 'drilled' to false  */
    var col:Number = 20; // number of columns in grid
    var row:Number = 20; // number of rows in grid
    for (g=1; g<=row; g++) {
              for (h=1; h<=col; h++){
                          drilled[g,h] = false;
    Very many thanks

  • Canon pixma pro 9500 having problems with my print out. colors are glazed and missing colors

    canon pixma pro 9500 having problems with my print out. colors are glazed and missing colors
    i have prfiled the mac and printer wiht colormunki and uplodated the profile sucessfully
    i set the printer to correct icc profile
    print out comes out same with glazed colors and missing tones/colors
    however when i use the same printer on windows and with light room, following same icc profile, colormunki calibrated profile, the print our are excellent.
    i have also tried using printer manage profile using the Mac and Aperture and get same poor prints
    can  you please assist and thanks

    I've a Pro9000 and also use Colormunki successfully.
    When I use Colormunki, I calibrate both of my monitors and the printer/paper combination. Colormunki saves the generated profiles to the correct places -- I don't load or change any profiles after that as that would mess-up what the Colormunki had just done for me, and this would likely mess-up the prints.
    Though I double-check the settings in the print dialogue, the choice for the printer handling things is already grayed-out. Colorsync handles it all just fine.

  • Problems with retrieving data from tables with 240 and more records

    Hi,
    I've been connecting to Oracle 11g Server (not sure exact version) using Oracle 10.1.0 Client and O10 Oracle 10g driver. Everything was ok.
    I installed Oracle 11.2.0 Client and I started to have problems with retrieving data from tables.
    First I used the same connection string, driver and so on (O10 Oracle 10g) then I tried ORA Oracle but with no luck. The result is like this:
    I'm able to connect to database. I'm able to retrieve data but from small tables (e.g. with 110 records it works perfectly using both O10 and ORA drivers). When I try to retrieve data from tables with like 240 and more records retrieval simply hangs (nothing happens at all - no error, no timeout). Application seems to hang forever.
    I'm using Powerbuilder to connect to Database (either PB10.5 using O10 driver or PB12 using ORA driver). I used DBTrace, so I see that query hangs on the first FETCH.
    So for the retrievals that hang I have something like:
    (3260008): BIND SELECT OUTPUT BUFFER (DataWindow):(DBI_SELBIND) (0.186 MS / 18978.709 MS)
    (3260008): ,len=160,type=DECIMAL,pbt=4,dbt=0,ct=0,prec=0,scale=0
    (3260008): ,len=160,type=DECIMAL,pbt=4,dbt=0,ct=0,prec=0,scale=1
    (3260008): ,len=160,type=DECIMAL,pbt=4,dbt=0,ct=0,prec=0,scale=0
    (3260008): EXECUTE:(DBI_DW_EXECUTE) (192.982 MS / 19171.691 MS)
    (3260008): FETCH NEXT:(DBI_FETCHNEXT)
    and this is the last line,
    while for retrievals that end, I have FETCH producing time, data in buffer and moving to the next Fetch until all data is retrieved
    On the side note, I have no problems with retrieving data either by SQL Developer or DbVisualizer.
    Problems started when I installed 11.2.0 Client. Even if I want to use 10.0.1 Client, the same problem occurs. So I guess something from 11.2.0 overrides 10.0.1 settings.
    I will appreciate any comments/hints/help.
    Thank you very much.

    pgoel wrote:
    I've been connecting to Oracle 11g Server (not sure exact version) using Oracle 10.1.0 Client and O10 Oracle 10g driver. Everything was ok.Earlier (before installing new stuff) did you ever try retrieving data from big tables (like 240 and more records), if yes, was it working?Yes, with Oracle 10g client (before installing 11g) I was able to retrieve any data, either it was 10k+ records or 100 records. Installing 11g client changed something that even using old 10g client (which I still have installed) fails to work. The same problem occur no matter I'm using 10g or 11g client now. Powerbuilder hangs on retrieving tables with more than like 240 records.
    Thanks.

  • HT201263 hello guyz i m having problem while restoring my iphone 4.It is showing me the 1600 error before that it showed 3194 error i fixed that after that it showed me the error 1601 also i fixed it but now with 1600 plz plz help me guyz

    hello guyz i m having problem while restoring my iphone 4.It is showing me the 1600 error before that it showed 3194 error i fixed that after that it showed me the error 1601 also i fixed it but now with 1600 more then 20 times tried but no advantage plz guyz help me?

    iTunes: Specific update-and-restore error messages and advanced troubleshooting - http://support.apple.com/kb/TS3694 - relating to iPad, iPhone, iPod touch, iTunes

  • Having problem with my iphone camera,doesnt work when i click the camera app,but it does work when i double click when my phone is off.

    having problem with my iphone camera,doesnt work when i click the camera app,but when i double click when my phone is locked it works.

    The Basic Troubleshooting Steps are:
    Restart..  Reset..  Restore...
    Reset your phone:
    Press the sleep/wake button & home button at the same time, keep pressing until you see the Apple logo, then release the buttons...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414

  • TS1702 Having problems with Security questions to be able to download from the iTunes store

    Having problems with Security questions to be able to download from the iTunes store

    Security questions
    Read this note for information on how to reset the security questions http://support.apple.com/kb/HT5312
    This user tip may also help you Security Questions

  • I am having problems shutting down my MacBook Pro.  I go to the apple and click shutdown or restart, it appears the shutdown process starts, the screen goes blue and the little circle keeps going round and round, but nothing happens even after 30 minutes.

    I am having problems shutting down my MacBook Pro.  I go to the apple and click shutdown or restart, it appears the shutdown process starts, the screen goes blue and the little circle keeps going round and round, but nothing happens even after 30 minutes.

    Make sure you quit all your applications before shutting down.
    And try resetting the SMC.
    Intel-based Macs: Resetting the System Management Controller (SMC)

  • Having problems getting podcast on iTunes, tried to resubmit and got an already submitted error

    Having problems getting podcast on iTunes, tried to resubmit and got an already submitted error. How can I get the podcast on iTunes?

    You didn't need to get it removed: you can make any changes to a feed that you want, changing, adding or deleting episodes, and iTunes will pick them up.
    However, in the present situation you have fallen over a bug in the submissions process. The workaround is changing the title; as this hasn't worked you need to change the feed URL if possible, and also you could change the contents of the 'link' tag.
    If you can't get it sorted you could try emailing Support at podcasts 'at' apple.com and asking them to reinstate you (give them all the details) - their responses are a bit variable, but they may help you.

  • Having problem sending e-mails.  There's a message on the screen saying that "the sender address was rejected by a server.

    I'm having problem sending e-mails.  There's a message on the screen after I press send saying that "The sender adress was rejected by a server.

    Check the outgoing mail server setting. Make sure that your username and password are in there.
    Settings>Mail, Contacts, Calendars>Your email account>Account>Outgoing mail server - tap the server name next to SMTP and check in the primary server and make sure your username and password are entered and correct - even if it says that the password is optional.

Maybe you are looking for