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

Similar Messages

  • I have used a 'for loop' to create an array of output data, however I want the each of the data sets from the array to be placed into a 1-D array. How do I concatenate the output of the for loop into a 1-D array?

    I am using this to create a data set that will be passed as an anolog output therefore it needs to have the correct array dimensions to go into the analog write vi.

    I'm updating my request... I've figured out how to do this by copying an example that uses a simple FOR loop (as seen in the attached current version of my VI). My question now becomes this: Is there a way to save the Y values corresponding to those X values into two more arrays? That is, just for argument's sake, let's say I took the first 100 elements from the X array, and found them to be positive. Then I would like to take the first 100 elements of the Y array and put them into a 'Y Values for X > 0' array. ...And likewise with the negative X values, they should have a separate array of corresponding 'Y values for X < 0' array.
    I can see that I should somehow save the indices of the positive X values from the large arrray wh
    en I sort them out, and use those indices to pick out the elements from the main Y array with the same indices.
    I just can't seem to set up the code necessary to do this. ...Can anyone help, please?
    Attachments:
    Poling_Data_Reader_5i.vi ‏79 KB
    30BLEND.txt ‏3 KB

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

  • Transposing data in an array using a For Loop

    I am trying to transpose some data in an array using a  for loop starting from the size of the array then decrement down to 0. Can someone please help if you have an example?
    Solved!
    Go to Solution.

    I feel as if reverse 1D array may help
    Edit: misunderstood what your second post meant.
    CLA, LabVIEW Versions 2010-2013

  • I'm creating an array using a for loop, how do I get the values outside the loop while it is running? thanks

    I'm creating a set of values using a for loop and a shift register inside the loop. I want access to these values outside the loop as they are being created inside. When I connect a wire from the shift register to a display outside, it doesn't work. How do I do this? Thank you.
    Attachments:
    tamko_new.vi ‏29 KB

    I tried to create the local variable that was wired to numeric indicator inside the loop. If I try to connect this to the analog output outside the loop, the loop just starts blinking and nothing happens, am I doing something wrong? Thanks again.
    Attachments:
    tamko_new2.vi ‏29 KB

  • What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?

    Hi All,
    I am new to TestStand. Still in the process of learning it.
    What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
    Thanks in advance,
    LaVIEWan
    Solved!
    Go to Solution.

    Hi,
    Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
    Regards
    Ray Farmer

  • Help with a FOR loop and an object array

    I need to make a for loop that takes an array of objects that contain the parameters year, type, and model (all ints) and sort by year, then divide the array in all the objects with the same year and sort them by type, then divide the array again into the objects with the same year AND type and sort them by model.
    the object a Dress objects, the get methods are get+nameof parameter.
    the array is a 1D array called Dresses.
    I have made a paralell array to store the value of the parameters and sort that then move the array acording to that sorted array. The problem is in the division of the array.

    We'll give your request to do (or finish) your homework for you the attention it deserves.

  • Weird problem with loading data from an XML using a for loop

    Hi,
    I have a strange problem. I have encountered this thing many a times but still don't know the proper workaround for it.
    I am trying to load swf file, a video file or an image. They can be present on a local system or on a remote server also. All the entries corresponding to the files to be loaded is made in an XML file. I traverse through the nodes of the XML using a for loop. On the complete event of loader info, example:.
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    I fill a container with the loaded data.
    My problem is when I am using for loop it doesn't works properly but if i use a statement like this:
    someFunc()
         if(i<arr.length())
         ... do something...
         loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    private function onComplete(e:Event):void
    ... do something...
    i++;
    All files are loaded properly.
    I think this can be because the for loop processes pretty fast but the content takes time to load, which ultimately leads to some wierd results.
    Please let me know how can this thing be done correctly by using a for loop also.

    You don't want to use a for loop to load several items.  The way you almost appear to have it is the proper approach... load a file and use the completion of its loading to trigger loading the next file.

  • 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

  • Iterating through every other (or specified number) of element in an array using a for loop

    I am trying to go through an array but instead of autoindexing I want to skip every other element or maybe a number of elements that will be specified for the user.
    Basic functionality that I want to acheive is the following in C code.
    int temp_var = 10;
    int i=0;
    for(i=0; i<=1000; i=i+temp_var)
    I am very new to LabVIEW and I did not know how to use internal variables.
    Can this be acheived using shift registers?
    I am attaching the code I currently have for this. Let me know what you think.
    Thanks guys.
    Solved!
    Go to Solution.
    Attachments:
    24_Sep_NchanNSamp.vi ‏44 KB

    tbob wrote:
    I have been asking for a new For Loop style that would allow us to specify start, stop, and step conditions, but it seems that many people are just not for this idea.  Don't know why?
    See here.
    I wouldn't say there aren't many people for it.  The idea you linked to was one of a half dozen of basically duplicate ideas, including another one of your own.
    These two ideas have a fairly large number of kudoes showing people want the idea.
    Smart Iterators with Loops
    For Loop Increment

  • How to use XSLT for mapping feild names one by one to array element

    I have a XSLT case to map all the attributes feild name(not value) which has no child to the target, which is array loop.
    I give an sample below.
    source:
    <Items xmlns="http://www.example.org/sample">
    <SourceSystem>SourceSystem2573</SourceSystem>
    <TimeStamp>2010-01-17T20:54:08.234</TimeStamp>
    <Item>
    <ID>2574</ID>
    <Type>2575</Type>
    <Name>2576</Name>
    </Item>
    </Items>
    source XSD like:
         <element name="Items" type="tns:ItemsType"></element>
         <complexType name="ItemsType">
              <sequence>
                   <element name="SourceSystem" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="TimeStamp" type="dateTime" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="Item" type="tns:ItemType"
                        maxOccurs="unbounded" minOccurs="1">
                   </element>
    </sequence>
         </complexType>
    <complexType name="ItemType">
              <sequence>
                   <element name="ID" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
                   <element name="Type" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
    <element name="Name" type="string" maxOccurs="1"
                        minOccurs="1">
                   </element>
    </sequence>
         </complexType>
    target need to be like:
    <ns1:AttributesCollection>
    <ns1:Attributes>
    <ns1:fieldname>SourceSystem</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>TimeStamp</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>ID</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>Type</ns1:fieldname>
    </ns1:Attributes>
    <ns1:Attributes>
    <ns1:fieldname>Name</ns1:fieldname>
    </ns1:Attributes>
    </ns1:AttributesCollection>
    target XSD:
    <xs:element name="AttributesCollection" type="AttributesCollection"/>
    <xs:complexType name="AttributesCollection">
    <xs:sequence>
    <xs:element name="Attributes" type="Attributes" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    </xs:complexType>
    <xs:complexType name="Attributes">
    <xs:sequence>
    <xs:element name="fieldname" minOccurs="0">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:maxLength value="100"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:element>
    </xs:sequence>
    </xs:complexType>
    I know we can use local-name() to get the tag/field name,
    but I have not idea how to get these leaf field names one by one and then mapping to every array elements.
    I tried whole day but no successful
    Does anyone have some idea?
    Thanks very much!
    Keith
    Edited by: user1065212 on 17-Jan-2010 22:50
    Edited by: user1065212 on 17-Jan-2010 22:53
    Edited by: user1065212 on 17-Jan-2010 22:59

    can you paste source xsd and the correct xml output, the current one isn't really valid
    <ID>2574</TotalNumOfItems>

  • Removing Items While Using New For Loop

    Consider this:
    ArrayList<String> a = new ArrayList<String>();
    ... add some stuff ...
    for(String s : a) {
    // Do some stuff
    if(some_condition) {
    a.remove(s);
    This will cause a ConcurentModificationException the a.remove(s) is ever run. Is there anyway to call the iterator.remove() method instead? The new syntax is much cleaner, and I'd like to use it, but I need to be able to call iterator.remove()
    Anyone?

    I think the code should iterate through a, putting
    references to objects in an auxillary array and then
    the loop will go through the auxilary array rather
    than the original data structure. This perfectly
    reasonable, but different implementation results in
    drastically different results (the example above would
    work fine). I see this as an issue of these general
    language features being defined to close to the metal.
    Their semantics are defined by their implementation
    not by a sound language design decision that is
    agnostic to different implementations.The enhanced for loop is defined in terms of java.lang.Iterable, a very simple interface, which can be implemented in many different ways. You can't get much farther from the metal. The concurrent modification exception is a feature of particular implementations of that interface. If you don't like those implementations, use others that behave differently. For example, you could use one of the CopyOnWrite collections implementations in java.util.concurrent, which never throw a concurrent modification exception. Your suggestion to copy the elements into an array is one (inefficient) implementation mechanism for such collections.

  • Can I use a for loop to add anonymous ActionListener objects?

    I have a setListener() method that has the following inside:
    for(int k = 0; k < buttons.length; k++)
        buttons[k].addActionListener(new ActionListener()
            public void actionPerformed(ActionEvent e)
                g2.setColor(colors[k]);
    }I have a JButton array and a Color array and I was hoping I could add them quickly in one shot rather than manually adding an anonymous ActionListener 9 times (I have 9 components). It tells me I need to make k final for an inner class and when I tested it by removing the for loop and keeping k as a final integer, it works. Is there a medium such that I can achieve what I want more or less while respecting Java's syntax?
    Any input would be greatly appreciated!
    Thanks in advance!

    s3a wrote:
    The local variable exists on the stack for as long as the method is executing. Once the method ends, that variable no longer exists. The newly created object, however, can continue to exist long after the method has ended. So when it's referring to variable X, it cannot refer to the same X as the one in the method, because that variable may no longer exist.Sorry for picking on little details but I am still not fully satisfied.
    Earlier I questioned if the local variable changed, but now let's say that that variable no longer exists at all, why does that even matter if the inner class copied the value and is keeping it for itself? What do you mean? The variable that existed in the method ceased to exist when the method ended. The inner class, however, can continue to live on, and can continue to refer to what we see as the same variable. However, it obviously can't be the same variable, since, in the world of the inner class, it still exists, while in the world of the method, it does not.
    This is completely independent of whether the variable changes or not. Regardless or whether the variable changes we still need two copies--one that goes away when the method's stack frame is popped, and one that lives on as long as the inner object does.
    Then, because there are two copies, the designers decided that the variable has to be final, so that they wouldn't have to mess with the complexity of keeping two variables in sync.
    That explanation leads me to believe that there is no copy and that there is some kind of "permanent umbilical cord" between the inner class and the local variable.Wrong. There has to be a copy. How else could the inner class keep referring to it after the method ends?
    Also, does marking it as final force it to be a permanent constant "variable" even if it's not a field "variable"? Or, similarly, does making a "variable" final make Java pretend that it is a field "variable"?Making a variable final does exactly one thing: It means the value can't change after it's been initialized. This is true of both fields and locals.
    As for the "pointless" byte-counting, I really don't see how it's confusing unless you're an absolute beginner. If I see somebody using a byte, I assume they have a real reason to do so, not pointless byte-hoarding. Then when I see that it's just a loop counter, I wonder WTF they were thinking, and have to spend some time determining if there's a valid reason, or if they're just writing bad code. Using a byte for a loop counter is bad code.
    I could then ask, why are people not using long instead of int and saying that that's using int is too meticulous?Part of it is probably historical. Part of it is because at 4 bytes, and int is exactly on word on the vast majority of hardware that Java has targeted since it came out. 8-byte words are becoming more common (64-bit hardware) but still in the minority.

  • Is it possible to use a "for loop" structure to represent DAQ of 16 channels?

    Hi,
    I tried to search but I failed to find a similar problem so I am posting this problem here.
    I have a temperature DAQ board which has 16 channels, and I am using all 16 channels to record and monitor temperature data.
    When I writed blocks for all 16 channels, a mess was created (as you can see in my attached program). I have noticed that all the VIs for the 16 channels have similar structure, so I was thinking whether we can represent all 16 channels with a "for loop" strucutre with a pointer i scanning from i=1 to 16 as we usually do in Matlab or Fortran.
    For instance, we may try to simplify the code like:
    for i=1:1:16
         acquire data from channel i
         show data from channel i in X-Y graph
         write data from channel i to excel in every 10 seconds
    end  
    I could not do it myself because I cannot find a "pointer" to represent each channel.
    Does anyone know how to do this in LabVIEW? Thank you.
    It is said that it is best if we can put all of our code within the screen of a monitor we use by using subVIs to divide the code into many subroutines. But I found it quite difficult to do so as I have too many controls as inputs and indicators as outputs. Also, I use property node to read and write frequently, which make things harder....
    Attached code does not work as it requires the 9213 hardware, and for simplicity I deleted irrelavent modules. But if you need I can upload one that may work by modifying the read VI.
    Thank you.
    Attachments:
    ask for help.vi ‏132 KB

    Yup, instead of all these 1D arrays, use a single 2D array. Your code could be reduce to <10% of the current size. I am sure it would fit easily on a single screen.
    Also try to do some tutorial or take some courses. I realy don't think you are ready to tackle a system of this magnitude at this time.
    Your code is just peppered with very poor choices. Some things you apparently haven't figured out:
    index array is resizable. There is no need to create dozens of parallel instances, all wired to the same array and all with a unique index diagram constant. If you want all elements in order, the indices don't need to be wired at all.
    Replace all your value property nodes with local variables. Much more efficient. Then redesign the code so you don't even need most of the local variables.
    You can use built array to append elements to an existing array. Using "insert into array" is much more complicated an error prone.
    It is not a good idea to have deeply stacked while loops with the innermost loop having long delays and indeterminate stop conditions. That just gums up the gears.
    Learn about proper code architectures, state machines, etc.
    Get rid of that gigantic, all encompassing stacked sequence. I am sure you can find a better way to reset three booleans when the code is about to stop. In fact it is typically more reasonable to set things to a defined state when the program starts to avoid problems due to accidental value changes at edit time.
    Don't use hidden control/indicators as data storage and interloop communication via local variables. There are better ways.
    You can wire the reminder or Q&R directly to a case structure. No need for e.g. "=0".
    Don't use ambiguous labels, e.g.a boolean labeled "Dampers on or off". Nobody will be able to later figure out if TRUE corresponds to ON or OFF. Could it be that TRUE mean it is either ON or OFF and FALSE that it is in some imternediate position?
    LabVIEW Champion . Do more with less code and in less time .

  • Create multiple VIs using a for loop

    Hi,
    I'm still pretty new to LabVIEW, so this question might be easy for you guys here..
    I'll simplify what I'm trying to do.
    I've got two numeric controllers that act as the rows and columns of a matrix.
    I'd like to take those numbers from these two controllers and use them to create a matrix of a certain picture.
    Example:
    The rows controller is given 3, and the columns controller is given 4.
    Using these numbers I would like the end result to show a certain image (let's say, a cube) multiplied on a 3 by 4 matrix.
    Let's say the picture is an X, then the end result should be:
    XXXX
    XXXX
    XXXX 
    I think I should be using a double for loop (one inside the other obviously), and I should also create the "position" property in order to display each picture of the cube in it's right place.
    The problem is that I don't know how to CREATE the pictures over and over again, while being able to control each one's position property.
    Any help would be GREATLY appreciated!
    Solved!
    Go to Solution.

    1) By "multiple VIs" I meant that I think that I need to create express VIs on the fly while running the for loop. I might be totally wrong here.
    2) Yes, by "numeric controllers" I meant numeric controls in the front panel.
    3) The matrix I'm referring too isn't an object nor a VI in LabVIEW but a virtual matrix that is the end result. I used the term "matrix" because the end result is actually a matrix (of rows and columns) of pictures..
    I'll try to elaborate and even simplify it more:
    Let's say I want to display one picture. That's easy, no problem there.
    Now let's say that I'd like to display n pictures on a one dimensional array. Just one row.
    What I think I need to do is to read from the numeric control in the front panel the number (n) of pictures, and then create them in a for loop, while using the "position" property to set the distance between each picture (using coordinates).
    My original question was just like the above, but for a two dimensional matrix/array. So I guess we can even simplify it even more, by saying it's only one dimensional.
    My way of action here might be totally wrong, and there might be an easier way or another way to go about this...
    Thanks for the quick answer!!  

Maybe you are looking for

  • SRM Process Controlled Workflow

    Hi Exports, I have created a Process schema for SC object type (BUS2121).. Looks like my process levels are trigged before the shopping cart is actually ordered by the user.. Is this a normal behavior? or I am missing any configuration? or I need to

  • How do I make changes to an external drive connected to my Mac mini from my Windows 7 PC

    I have an external drive which I learned had to be FAT32 for the read write option to be set in the Mac Mini.  I did that and moved all the media files back on the external HDD.  On the Mac Mini, I shared the 4 folders I needed (Ebooks, Movies, TV Sh

  • WinXP and MSI 845PE MAX2

    Got the following problem. I've just purchased an MSI 845PE MAX2 (MS-6704) with a PIV 2,4ghz 533 processor and 512mb DDR PC2700. Onboard USB/FIREWIRE/LAN and ATA133raid are enabled. My graphics card is a Matrox G400 which is using IRQ10. I have 3 HDD

  • Use GPO to set default language options, IME, display settings?

    new to GPO, we have a small Windows Server 2012 domain, all clients on Win7 or Win8.  All the clients require the following changes, anything I can automate this with GPO?  thanks Under Control Panel\Clock, Language, and Region\Language > Add Traditi

  • Regarding Qualifiers in IDOC Segments

    Hello Experts, We are using IDOC Type INVOIC02 to post the vendor invoices from the Vendor into SAP. We have segment E1EDS01 with the SUMID where they have used a custom Qualifier 'Z05'. The Domain SUMID has no entry for the Qualifier 'Z05' but the I