Using a For Loop Index for Array Element Number?

Hi.  Thanks in advance for the help.  I can't seem to find what I want to do here using the search function... probably because I don't know how to frame the question appropriately.  Ignore the title to this post cause it's probably wrong vocabulary for what I want to do.
Here's the situation:
I have a 2D array where the first column is the X data and each subsequent column is Y data (call it Y1...Yn).  The n-value varies from run to run (some runs have 4 columns of data, some have 20), but that is easily gathered when reading the data file.  I need to perform a number of operations on each set of data, the least of which is smoothing the data and graphing it, so I'm limiting my discussion to these 2 operations.
What I want is a for loop structure where the indexing of the loop tracks the Y1...Yn columns, grabs each column for the iteration, performs the relevant analysis, and spits out the result, but in a stackable manner.  Thus the title; I want to use the for loop's index to mark the array element for building a new array.
See the image attached.  A 2D array of 9 columns (X, Y1...Y8) is analyzed such that each data set, (X, Y1), (X, Y2)...(X, Y8) is bundled, graphed, run through a B-spline Fit, of which is also graphed.  I need to replace this with something that looks like the for loop structure shown.  
I just don't know how to get those two data bundles [(X, Yi) and it's smoothed pair] out of the for loop in a stacked set from every iteration of the for loop.
Again the title, I think I want to build a new array where i use the index of the for loop to control the entries of the new array.  But I can't see how to do that.
Any help would be appreciated.
Attachments:
NeedForLoopForThis.PNG ‏30 KB

Hello H.R. Dunham, and welcome to the forum!
It seems that you may be looking for Auto-Indexing, a basic feature of loops in LabVIEW.  You'll need to transpose your array before wiring it into the for loop, as elements are auto-indexed by row before column, but at that point you should be able to operate on each column and output an array of n cluster elements corresponding to your input columns.  Auto-indexing tunnels look like brackets to indicate each element will be indexed automatically- this should be the default when wiring an array into a for loop or when wiring anything out of a for loop.
As for how to build your pairs, I suggest removing the X column and creating a "starter" cluster containing your X data and placeholder Y data before entering your "Y" processing loop.  Use the bundle by name function in the for loop to insert your processed column data into the cluster and auto-index the cluster output. Flow would be something like this:
1) Gather data
2) Split X and Y using standard array operations
3) Create "template" cluster with shared X data
4) Pass template cluster and Y-column array into an auto-indexed for loop.
5) Insert processed Y data into cluster inside loop.
6) Auto-index cluster data out of loop.
This tutorial is probably also a good place to get started:
Getting Started with NI LabVIEW Module 3: Loops
http://www.ni.com/white-paper/7528/en/
Hope that helps!
Regards,
Tom L.

Similar Messages

  • For loop indexing?

    Is it possible to change indexing step in labView "For Loop" structure? By
    default this value is 1, and I need to make a step value different from "1"
    like in C example:
    for (index=0; index < 100; index++) {}; // step=1
    for (index=0; index < 100; index=index+3) {}; // step=3
    Sergey Yakovlev, Berlin,
    [email protected]

    Hallo, Sergey,
    Du (yakovlev) meintest am 21.09.01 zum Thema for loop indexing?:
    > Is it possible to change indexing step in labView "For Loop"
    > structure? By default this value is 1, and I need to make a step
    > value different from "1" like in C example:
    > for (index=0; index < 100; index++) {}; // step=1
    > for (index=0; index < 100; index=index+3) {}; // step=3
    What about
    j:=i*3
    and i is incremented by 1
    Greetings!
    Helmut
    Please excuse my gerlish!

  • Question about using for-loop to generate array from DAQmx. Thanks!

    I have a laser system with a frequency of 1kHz, I am using this 1kHz signal to trigger the DAQmx and get the data from a photodetector, e.g. I will get 1000 data points during 1 second from DAQmx, but I need to separate this 1000 data points into the even and odd list, which is two list of 500 data points, e.g.. The 1st, 3rd, ... 99th data is one array, the 2nd, 4th,... 10th data is another array, then I will do further calculations based on these two arrays.
    To seperate the even and odd data, the only way I can find is put these 1000 points into an array and then seperate them afterwards.
    Can I do things like this pic?
    I don't know the speed of the for loop, because the 1kHz trigger is always there, once it is triggered, the DAQmx read will give a data point, if the speed of the for-loop( the time from the end of a loop to the beginning of the next loop) is slower than the 1kHz trigger, then the for-loop will miss data point, then the ordering of the 1000 points in 1 second will be changed.
    Or I need to put everything, e.g. AI Voltage, Trigger, sample clock, into the for-loop and then return a Y? Thanks! 

    Clarification:
    The VI you have posted will work as following:
    1) The task will read 2 analog inputs (ai0, ai3).
    2) The acquisition starts, oncece digital signal (trigger) is detected on PFI0
    3) The sampling rate will be as specified in "rate" control - it is continuous analog input acquisition, which means that after trigger is received (point 2), the board will start to generate hardware clock with frequency you specify as "rate"
    4) with each rising edge of that hardware clock, the measurement is taken, and stored into buffer of driver.
    5) DAQmx read will try to read "number of samples per channel" number of samples each time is called - and if there is not enough measurement stored in buffer (step 4), then DAQmx read will wait until DAQ card will measure reaquested number of samples (or timeout occurs before requested number of samples has been acquired)
    6) DAQmx read will be then called 1000 times - so totaly you will read 1000 * "number of samples per channel"  number of samples.
    You do not have to be worried about speed of the loop. In fact, if you need to read just 1000 samples, with 1kS/s, then you can remove for loop and you can change measurement mode from continuous to finite samples, and specify number of samples to read to be 1000. You will read them all properly. I recomend you to read User Manual for your DAQ device - lets say M Series User Manual.
    I hope it is clear now.
    regards,
    stefo

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Please help with the FOR loop and the array..

    I was trying to place some words in the Movie Clip
    "TextPanel" and set a
    random position to each of them.
    But it's not working.
    1) I created a Movie Clip "word" and inside that MC I created
    a text field
    and gave it an identifier "textFiled".
    2) The linkage name for Movie Clip "word" I set to "word".
    3) In the actionscript I created an Array called "aWords".
    4) Then I created a FOR loop that should
    place (attach) Movie Clips "word0", "word1", "word2" and
    "word3" to the
    movie clip TextPanel, and set the textField text for each of
    them to the
    text from the Array.
    But the script attaches 4 Movie Clips with a name
    "Undefined", instead of 4
    different names (from the Array).
    What is wrong with this script?
    var aWords:Array = [apple,banana,orange,mango];
    for(i=0;i<aWords.length;i++){
    var v = TextPanel.attachMovie("word","word"+i,i);
    v.textFiled.text = aWords
    v._x = randomNumber(0,Stage.width);
    v._y = randomNumber(0,Stage.height);
    Thanks in advance

    But in my Post I already wrote v.textFiled.text = aWords
    so I don't understand what were you correcting..
    And one more:
    I have tested it by changing the
    v.textFiled.text = aWords; to v.textFiled.text = "some
    word";
    and it's working fine.
    So there is something wrong with the Array element, and I
    don't know why..
    "aniebel" <[email protected]> wrote in
    message
    news:ft2d5k$lld$[email protected]..
    > Change:
    > v.textFiled.text = aWords;
    >
    > to:
    > v.textFiled.text = aWords
    >
    > It needs to know which element inside the array you want
    to place in the
    > textfield (or textfiled) :)
    >
    > If that doesn't work, double check that your instance
    name is correct
    > inside
    > of "word".
    >

  • TREX on Portal-Server also used for search/index for SAP Records Management

    Hi all,
    can a installation of the TREX on the Portal-Server (or as separate Server) used for Portal Index/search and also in parallel for searching of Content in an SAP Records Management (means full text research of records/ dossier in the SAP RM) ? Some ideas, tips or settings to keep in mind ?
    THX
    mario

    Hi Neil,
    We have exactly the same problem. We installed a new SAP E-Commerce system on Microsoft Windws 2008 R2 with TREX Version 7.10.43.00. The TREX connection is okay. Also the catalogue replication works without any problems. The SAP support means it is a permission problem on the IIS. The problem isnu2019t solved yet and the message to the SAP support is in process.
    What is your effect with this link?
    http://localhost:<TREXNAMESERVER>/TREXHttpServer/
    Default:
    http://localhost:<30305>/TREXHttpServer/
    Kind regards,
    Roland

  • How do u create a 2-dim. vector with a for loop(two for's) ?

    JTable is such a pain in the ass sometimes... you see i don't have a predifined number of elements to be stored in the JTable... so i have to pass a Vector[][] but i don't know how to create one in two for loops...
    Vector v[][] = new Vector[][];
    for(int i = 0; i< v.size(); i++){
    for (int j=0; j<v.size(); j++){
    v[i][j] = { "" + (u+1) , ((Team)c.get(array[u])).getName()),
    intoString(((Team)c.get(array.getPlayed()))),
    intoString(((Team)c.get(array[u].getHomeWins()))),
    intoString(((Team)c.get(array[u])).getHomeDraws()),
    intoString(((Team)c.get(array[u])).getHomeLosses()),
    intoString(((Team)c.get(array[u])).getHomeFor()),
    intoString(((Team)c.get(array[u])).getHomeAgainst()),
    intoString(((Team)c.get(array[u])).getAwayWins()),
    intoString(((Team)c.get(array[u])).getAwayDraws()),
    intoString(((Team)c.get(array[u])).getAwayLosses()),
    intoString(((Team)c.get(array[u])).getAwayFor()),
    intoString(((Team)c.get(array[u])).getAwayAgainst()) ,
    intoString(((Team)c.get(array[u])).getPoints()) } ;
    It doesnt work this way because my layout in JTable later needs to be like this....
    uuuuuu uuuuuuuuuuuuuu uuuuuuuuuuuu uuuuuuuuuu
    666666 66666666666666 666666666666 6666666666
    777777 77777777777777 77777777777 7777777
    .. and so and so... do u follow me ??
    Please help me if you can ....

    I might still be mising the point but here goes.
    According to the API ( http://java.sun.com/j2se/1.3/docs/api/index.html ) for JTable, the appropriate constructor is:
    public JTable(Vector rowData, Vector columnNames)
    I'm assuming that the JTable should have one column for each of the items - Name, Played, HomeWins etc. I'll also assume there is an array of Team objects containing the data (if I'm wrong the code should be easy to adjust).
    The columnnames Vector is self-explanatory - add a String object for each column.
    For rowData, you need a Vector of Vectors.
    e.g
    Vector rowData = new Vector[teamArray.length];
    for (int k = 0; k < teamArray.length; k ++) {
      Vector oneRow = new Vector();
      Team team = teamArray[k];
      oneRow.add(team.getName());
      oneRow.add(team.getPlayed());
      oneRow.add(team.getPoints());
      rowData[k] = oneRow;
    JTable table = new JTable(rowData, columnNames);

  • Using a For Loop with an array

    Ok, the issue is with the enabling of the buttons on my
    stage. I run a loop to deactivate them all when one is clicked,
    then I want to turn them back on, EXCEPT the one which was clicked.
    I thought I could start off with an array of MC names and simply
    delete them from the array. But I can't get my head around exactly
    how to read in the array contents as MC names...
    Any help would be greatly appreciated.
    Mike

    Try something like this:

  • Can I use Argo to create Indexes for Structured data?

    Hi, To search for employees who has stored some <i>word</i> in an infotype's text cluster takes time, specially when we also want those who has an relation in infotype 1001 to an object which again is connected to some other object where <i>word</i> appears in infotype 1002 - subtype 0001.
    Open SQL cannot select directly from text clusters, so we need to read all entries for all employees an the scan the entries for <i>word</i>. So an index which connects <i>word</i> or <i>this is a phrase</i> or  <i>department - description - all parent org.units</i> with employees would be nice to build to replace the open SQL.
    The question is if Argo is a solution to build, develope, store and administrate such indexes?
    Robert

    Hello Robert,
    Argo by itself does not index the content. Its our search engine TREX which does the indexing and searching.
    If you are using ERP 2005, quite a few objects are already indexed by TREX. We have a Framework services called SES (Search Engine Services) which expects you to implement couple of methods viz. 1) the data to index and b) any updates to the index. SES interacts with TREX to index the content.
    Regards,
    Bala.

  • Please help for create index for table in db2

    Dear Consultants,
    Our Production Servers have a problem, when user input materials in t-code VA01, the check data take long time to complete.
    I was create a incident on SAP Portal and they recommended to create a new index on table:
    VBRP in the order MANDT, AUBEL and AUPOS.
    but we don't sure how to do this, please help us !
    The SAP consultant message:
    " It was identified that there is one SQL statement which was
    responsible for the majority of the time spent during the VA01
    transaction. It accounted for around 49 seconds.
    The SQL statement was analysed and a selectivity analysis was carried
    out on certain fields specified in the WHERE clause. The statement is
    currently executed via a full table scan which is not an efficient
    access. It is therefore recommended to create a new index on table
    VBRP in the order MANDT, AUBEL and AUPOS. "
    Our System Landscape IS : DEV -> QAS -> Production and DataBase server : db2 9.07 , SAP ECC 6.0, windows server 2008
    Thanks and Best Regards,
    Hien Nguyen

    Hi Deepak,
    Could you please tell me the places where can i post the message for ABAPer, i don't know to choose : ABAP Development , ABAP Testing and Troubleshoo… or somthing else
    Sorry for my amateur !
    Thanks you very much.
    Best Regards,
    Hien

  • Using a For loop to call one array element at a time

    I have been working on a VI that reads a GPS unit, parses the data, outputs what I need, compares the actual GPS location to the desired location, determines a desired heading and moves on from there.  My question pertains to the number of desired locations I can input right now.  I need to be able to input a predtermined number of locations (not just the one that I can input right now).  I was told that it is possible to use a For Loop with an array and have the first set of Lat and Long values run through the VI and when everything is complete that the next set of values will be chosen.  Does this mean that I need to put the entire VI inside a For Loop and have the array update as soon as the VI has completed its first mission?  I understand the concept of how this work from other programming languages but I'm not sure how to implement the solution in LabVIEW.  Any help would be appreciated.
    Adam

    adamoutlaw wrote:
    Here is a portion of the VI.  I need two separate arrays, one for Latitude and one for Longitude, of the same size.
    I don't see any arrays in your code. Do you want to generate arrays form individual data points or do you want to process arrays, one element at a time? Both can take advantage of autoindexing. Here's a simple picture.
    Your VI contains a weird mix of DBL and EXT precision. Most likely all you need is DBL. Keep your representations consistent!
    Message Edited by altenbach on 08-02-2007 07:14 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Indexing.png ‏4 KB

  • Problem cycling through elements of an array using a for loop ~ error 200609?

    Hi,
    I'm outputting a 194-element array from a MATLAB script node into a for loop where the array is indexed then converted into a 8-bit boolean pattern which I'm trying to output using DAQ Assistant. I'm using LabVIEW 8.2 and a PCI 6133 DAQ using a counter(Ctr0InternalOutput) to time the output. The first element of the array goes through the loop perfectly however never makes it's way back through and throws error 200609: Generation cannot be started because the slescted buffer size is too small. Increase the buffer size. After probing the line before DAQ Assistant I confirmed only one element makes it through the loop and then throws this error? I've trying doing the same things with lower lowel DAQmx vi's using a DAQmx configure output buffer vi to override this buffer size problem, but still get the same result(not the error but same data flow problem)? Anybody know what's going on? I've included the vi's I've been working with. Thanks!
    Millie
    Attachments:
    Untitled 22.vi ‏228 KB
    Untitled 34.vi ‏180 KB

    Hi,
    I'm outputting a 194-element array from a MATLAB script node into a for loop where the array is indexed then converted into a 8-bit boolean pattern which I'm trying to output using DAQ Assistant. I'm using LabVIEW 8.2 and a PCI 6133 DAQ using a counter(Ctr0InternalOutput) to time the output. The first element of the array goes through the loop perfectly however never makes it's way back through and throws error 200609: Generation cannot be started because the slescted buffer size is too small. Increase the buffer size. After probing the line before DAQ Assistant I confirmed only one element makes it through the loop and then throws this error? I've trying doing the same things with lower lowel DAQmx vi's using a DAQmx configure output buffer vi to override this buffer size problem, but still get the same result(not the error but same data flow problem)? Anybody know what's going on? I've included the vi's I've been working with. Thanks!
    Millie
    Attachments:
    Untitled 22.vi ‏228 KB
    Untitled 34.vi ‏180 KB

  • How to index a array to give it to for loop for one value at a time sequence to be ensured

    I need to give one number from a array at a time to a for loop. means the for loop have to execute one number at a time  from a array of numbers. How to do it

    Ranjeet,
    Ranjeet_Singh wrote:
    But question is same only. is in it ?
    With all due respect, NO.
    Please make sure you know what you are talking about before blatantly countering someone else's comment. Can you prove that your vi and TiTou's snippet will do the same thing?
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • How do we use if statement in labview?moreover can i use if statement inside for loop?

    how do we use if statement in labview?moreover can i use if statement inside for loop?

    The if statement in LabVIEW is the Case structure. You can find that on the Structures palette right next to the For Loop. If you're still on the same subject about terminating a for loop early, then what you do is enclose your functions inside the loop with a case statment and make one of the case's empty except for one or more constants that you might have to wire. Hopefully, the attached picture will explain what I mean. Also, as I mentioned in one of your other posts, I think this technique is not as good as using a while loop. The array in the attached example is the same size no matter what and you may have to handle stripping extra or invalid elements.
    Attachments:
    For_Loop_with_Case.jpg ‏21 KB

  • 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.

Maybe you are looking for