Como recorrer un array dentro de un for?

Es decir, ¿como hacer esta secuencia en labview? no doy con la solución.
v = [0.5, 1, 5, 8, 10, 20, 35, 50];
int n;
for (int i = 0; i < v.size(); ++i) {
    n = v[i];
Uso labview 7.1
Saludos.

Hola, un string de dos bytes no puede contener un double ya que el dbl es un número de 8 bytes.
Acaso estás recibiendo alguna medicion de un conversor de 16 bits (un instrumento externo, un PIC o algo así)? Si es así el valor correspondiente en la unidad de medición (V, A, RPM...) debe calcularse con
    bits recibidos / 65536 * máximo de la medición
Ejemplo: en un voltímetro de 100V / 16 bits, un valor de 8000 (bits) equivale a una medición de 12.207V
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos?

Similar Messages

  • Use column in 2d array as page number for 3d array

    I have a 2D array coming from a database containing (I simplify a bit for this example)
    column 0: plot number
    column 1: x values
    column 2: corresponding y values
    to be able to process everything and later put it in a graph, i would like to convert it into a 3d array where the page number is the plot number (so column 0) from my original array. I tried two different approaches you can see in the attachment, both give unwanted results:
    1. the resulting array contains two pages with only x2 and y2 for each plot
    2. the resulting array contains two pages with only x1 and y1 for each plot
    What am i doing wrong here?
    As a second difficulty the order in the example 2d array is logical (x1 of plot 1, x1 of plot 2, x2 of plot1.....) .
    The order in the actual array might just as well be as the example in the second attachment
    Thanks!
    Attachments:
    bad order.PNG ‏2 KB
    Move column to page.PNG ‏18 KB

    Attached (LV 8.0) is something I quickly whipped up using the above 2 assumptions as being true. I did not fully test this, so be sure to put it through its paces.
    Your solutions centered on using Insert Into Array. The reason this won't work is because your first x/y pair could be from plot 1 (the second page). But, you cannot insert a second page into an empty array.  I opted for pre-creating the 3D array and then using Replace Array Subset. 
    OK, I posted this before I got the notification that you answered my questions. Given that, then how is one supposed to know the order of the X/Y pairs? Obviously, your example used strings for demonstration. Presumably the real values will be numbers. In this case, how is one supposed to know where to place the new X/Y pair?
    Corollary: Arrays must be rectangular. This means that if plot 0 has 3 XY pairs, but plot 1 has 5, then the 3D array MUST have 5 rows for each page. This means you will have empty rows on page 0. Given this, you are better off creating an array of clusters. Each cluster would contain your XY pairs as a 2D array, and each one can have different number of rows, as shown in this figure:
    Message Edited by smercurio_fc on 03-11-2009 10:43 AM
    Attachments:
    2D Array to 3D Array.vi ‏17 KB
    Example_VI_FP.png ‏5 KB

  • Need a array within an arraycollection for the arraycollection to run the filterfunction properly?

    Do you need to have an array within an arraycollection for
    the arraycollection to run the filterfunction properly?
    <mx:ArrayCollection id="arrColl">
    <mx:source>
    <mx:Array>
    <mx:Object name="ColdFusion" value="0.00" />
    <mx:Object name="Dreamweaver" value="0.12" />
    <mx:Object name="Fireworks" value="1.01" />
    <mx:Object name="Flash" value="0" />
    <mx:Object name="Flash Player" value="-0.00" />
    <mx:Object name="Flex" value="0.00" />
    <mx:Object name="Illustrator" value="2.92" />
    <mx:Object name="Lightroom" value="0.32" />
    <mx:Object name="Photoshop" value="0.06" />
    </mx:Array>
    </mx:source>
    </mx:ArrayCollection>

    "nikos101" <[email protected]> wrote in
    message
    news:gb07gv$9v8$[email protected]..
    > Do you need to have an array within an arraycollection
    for the
    > arraycollection
    > to run the filterfunction properly?
    >
    > <mx:ArrayCollection id="arrColl">
    > <mx:source>
    > <mx:Array>
    > <mx:Object name="ColdFusion" value="0.00" />
    > <mx:Object name="Dreamweaver" value="0.12" />
    > <mx:Object name="Fireworks" value="1.01" />
    > <mx:Object name="Flash" value="0" />
    > <mx:Object name="Flash Player" value="-0.00" />
    > <mx:Object name="Flex" value="0.00" />
    > <mx:Object name="Illustrator" value="2.92" />
    > <mx:Object name="Lightroom" value="0.32" />
    > <mx:Object name="Photoshop" value="0.06" />
    > </mx:Array>
    > </mx:source>
    > </mx:ArrayCollection>
    You have to have an Array within the ArrayCollection for it
    to do anything,
    since ArrayCollection is just a wrapper for Array...

  • Como obtener un array dbl de un string de 2 bytes

    como obtener un array dbl de un string de 2 bytes
    Adjuntos:
    dbl.png ‏37 KB

    Hola, un string de dos bytes no puede contener un double ya que el dbl es un número de 8 bytes.
    Acaso estás recibiendo alguna medicion de un conversor de 16 bits (un instrumento externo, un PIC o algo así)? Si es así el valor correspondiente en la unidad de medición (V, A, RPM...) debe calcularse con
        bits recibidos / 65536 * máximo de la medición
    Ejemplo: en un voltímetro de 100V / 16 bits, un valor de 8000 (bits) equivale a una medición de 12.207V
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • Need an ARRAY of the values for the user to see the array values

    how would I display the values to the user in an array?????
    for all three loans in my java code
    import java.text.*;           //20 May 2008, Revision ...many
    import java.io.IOException;
    class memortgage     //program class name
      public static void main(String[] args) throws IOException
        double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal
        double rate [ ] = {.0535, .055, .0575};          //the three interest rates
        int [ ] term = {7,15,30};                        //7, 15 and 30 year term loans
        int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0;
        char answer,test;
        boolean validChoice;
        System.in.skip(System.in.available());           //clear the stream for the next entered character
        do
          validChoice = true;
          System.out.println("What Choice would you Like\n");
          System.out.println("1-Interest rate of 5.35% for 7 years?");       //just as it reads for each to select from
          System.out.println("2-Interest rate of 5.55% for 15 years?");
          System.out.println("3-Interest rate of 5.75% for 30 years?");
          System.out.println("4-Quit");
          answer = (char)System.in.read();
          if (answer == '1')  //7 yr loan at 5.35%
            ratePlace = 0;
            firstIterate = 4;
            secondIterate = 21;
            totalMo= 84;
          else if (answer == '2') //15 yr loan at 5.55%
            ratePlace = 1;
            firstIterate = 9;      //it helps If I have the correct numbers to calcualte as in 9*20 to equal 180...that why I was off -24333.76
            secondIterate = 20;    //now it is only of -0.40 cents....DAMN ME
            totalMo = 180;
          else if (answer == '3') //30 yr loan at 5.75%
            ratePlace = 2;
            firstIterate = 15;
            secondIterate = 24;
            totalMo = 360;
          else if (answer == '4') //exit or quit
            System.exit(0);
          else
            System.in.skip(System.in.available());               //validates choice
            System.out.println("Invalid choice, try again.\n\n");
            validChoice = false;
        }while(!validChoice);  //when a valid choice is found calculate the following, ! means not, similar to if(x != 4)
        for(int x = 0; x < 25; x++)System.out.println();
        amount = (principal + (principal * rate[ratePlace] * term[ratePlace] ));
        moPay = (amount / totalMo);
        totalInt = (principal * rate[ratePlace] * term[ratePlace]);
        DecimalFormat df = new DecimalFormat("0.00");
        System.out.println("The Interest on $" + (df.format(principal) + " at " + rate[ratePlace]*100 +
        "% for a term of "+term[ratePlace]+" years is \n" +"$"+ (df.format(totalInt) +" Dollars\n")));
        System.out.println("\nThe total amount of loan plus interest is $"+(df.format(amount)+" Dollars.\n"));
        System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be $"+
        (df.format (moPay) + " Dollars a month\n\n"));
        System.in.skip(System.in.available());
        System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit");
        answer = (char)System.in.read();
        if (answer == 'y')
          System.out.println((term[ratePlace]*12) + " monthly payments:");
          String monthlyPayment = df.format(moPay);
          for (int a = 1; a <= firstIterate; a++)
            System.out.println(" Payment Schedule \n\n ");
            System.out.println("Month Payment Balance\n");
            for (int b = 1; b <= secondIterate; b++)
              amount -= Double.parseDouble(monthlyPayment);
              System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount));
            System.in.skip(System.in.available());
            System.out.println(("This Page Is Complete Press [ENTER] to Continue"));
            System.in.read();
    }

    skull_innocent wrote:
    whooooooo...dang....just tell me nicely .
    Sorry.
    I thought that this question I submitted in the wrong area previously
    There are better ways to correct me in my errors for posting
    I am sorry.Okay, no harm done.
    I hope that you understand that a major beef of contributors here is to spend time answering a question, only to later discover that somebody else has posted a similar answer in another thread. Hence the annoyance at crossposters.
    In the future, if you think you've posted in the wrong forum, or if for whatever reason you decide to post in multiple forums, pick one thread as the "main" one and provide a link to it in the others.

  • The size limit of the OCI LOB Array Insert is 64K for one field?

    I have a table with 4 field, and one is BLOB field. I want to insert 16 rows in one OCIStmtExecute. I know I can specify the iter parameter with 16 to execute sql 16 times.
    I found example in "Application Developer's Guide - Large Objects" in page "Data Interface for Persistent LOBs 13-17", there is a example function called "array_insert". It shows the usage of OCIBindArrayOfStruct, but can only insert LOB with same size, the LOB field of each row filled with the same size data.
    But I have to insert LOB with different size, for example 8K for row 1, and 16K for row 2, 128K for row 3. Than I find the alenp parameter of OCIBindByName/OCIBindByPos. It is "pointer to array of actual lengths of array elements."(OCI document). So I think I find the solution for my problem. But the type of alenp parameter is ub2*, is it means I can only insert 64K data for each row in my array insert? It is too small, I hope I can array insert BLOB with 16M each row.
    Or there is any other solution for my problem? I look forward to it for a long time! thanks every one!

    It is called Data Interface to work with LOB datatypes by APIs designed for use with legacy datatypes. I can specify SQLT_BIN to bind memory binary data to BLOB column, and INSERT or UPDATE directly. It can be without LOB locator and save round-trip to the server. This is very fit my needs, because I have to insert very much BLOBs to server as soon as possible.
    I have make a test program, and multi-row with different size blob( less than 65536 bytes) can be insert at one time, without locators. Multi-row wiht same size blob( more than 64K) also can be insert at one time--the alenp parameter is not used. I only can not insert multi-row with different size blob( more than 64k) because the type of alenp is ub2*.
    thank you for your reply!

  • How to implement index array inside case structure for searching a 3D array?

    Well I have a 3D array and I want to index certain elements from that array. And I have thought of one way of doing this is to have multiple index array functions on the block diagram to search the array simultaneously, but that would be messy. Or I could setup some kind of case structure and place each index array function into individual cases. I've tried the latter, but when I connect the 3D array to the case structure at the"?" it doesn't give me permission because it says I'm hooking up two different types of data. Case Structure is for T or F and 3D array is not a boolean.
    So how can I setup the Case Structure to work for a 3D array?

    A case structure's selection tunnel cannot accept an array.  What exactly are your search criteria?  It sounds like a few FOR loops will be needed.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Load image pixels in 2D array - Duke Dollars up for grabs :)

    Hi everyone!
    I am writting a program that will work from a 2 dimensional array to get the location of any pixel (x and y) coordinates and it's color in an int format. I must apologise for my request but I do not have the slightest clue about images and all I know is how to load one and then display it. Can somebody provide the source code for representing an 50x50pixel .gif image in a 2D array with the index of the array being (x coordinates and y coordinates) and holding the color in int format and I will be eternally greatefull.:)
    Your humble servant,

    Thanks for the code but the functionality i need is
    setting the array to contain all the pixels of my
    image.
    Can you please tell me how I can do that?!
    Image imge;
    imge=getToolkit().getImage("icon.gif");The way i will do:
    Create a buffered Image 50*50
    get the graphics for this image
    draw your image into the buffered Image
    use getRGB(x,y) to get the pixel
    Image imge;
    BufferedImage bi;
    Graphics      gi;
    Color[]       col = new Color[2500];
    imge=getToolkit().getImage("icon.gif"); 
    bi = new BufferedImage(50,50,BufferedImage.TYPE_3BYTE_BGR);
    gi = bi.getGraphics();
    gi.drawImage(imge,0,0,null);
    for (int x = 0; x < 50; x++)
         for (int y = 0; y < 50; y++)
              col[x*50+y] = bi.getRGB(x,y));  
    [/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Efficientl​y building an array of increasing values for a graph

    I need to build an array of values increasing by 3E-8.  Initializing an array and changing each value in a while loop works fine, but it is terribly slow.  Is there a better (faster) way of building an array of increasing values like this?

    Thanks for the suggestion, it looks like that could do what I'm looking for.  A kind tech solved the problem for me by phone -- I knew it was reading and writing the entire 100,000 element matrix to memory at each step, but I couldn't figure out how to get it to stop.  A shift register brought the run time from over 2 minutes to under 1 second.
    Thanks again for responding!
    Message Edited by Deamiter on 11-07-2006 06:46 PM

  • How to avoid Build Array function inside a For (while) Loop?

    Hi there,
    I have a simple question about how to avoid using Build Array function inside the loop. Now I want to remove the Build Array funtion inside the loop to improve the performance (To get better memory management). Any idea how to do that?
    Thanks a lot!
    Warmest regards,
    Chong

    It's been my experience that using the auto-indexing to build an array
    on a For loop is just as good as initializing and replacing elements.
    The For loop knows before it runs how many iterations it has to run and
    can allocate the array ahead of time.
    You're better off initializing and replacing when using a While loop
    because it does not know how many iterations it will run and can't
    pre-allocate the array ahead of time.
    Ed
    Ed Dickens - Certified LabVIEW Architect - DISTek Integration, Inc. - NI Certified Alliance Partner
    Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.

  • Using Assoc Arrays in OBPM 10GR3 for 25 million comparisons

    Can we use Associative arrays in OBPM 10GR3 to do 25 million comparisons or even more than that?
    I have two assoc arrays which I compare with each other 25 million times by looping them one inside the other.
    For e.g.
    for(int i = 0; i < 5000; i++)
    for(j=0; j < 5000; j++)
    if(i==j)
    logMessage ("The value is equal");
    when I try to do that, I get an error:-
    Persistence Data error.
    I get this error:-
    Error while persisting the transaction data: 'An error occurred while accesing the database. Detail:SQL statement: 'unknown' ' Details: An error occurred while accesing the database. Detail:SQL statement: 'unknown' Caused by: Unexpected exception while enlisting XAConnection java.sql.SQLException: Transaction rolled back: Transaction timed out after 302 seconds BEA1-25BFB4A4F3934EFC9C00 at weblogic.jdbc.jta.DataSource.enlist(DataSource.java:1418) at weblogic.jdbc.jta.DataSource.refreshXAConnAndEnlist(DataSource.java:1330) at weblogic.jdbc.wrapper.JTAConnection.getXAConn(JTAConnection.java:189) at weblogic.jdbc.wrapper.JTAConnection.checkConnection(JTAConnection.java:64) at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:92) at weblogic.jdbc.wrapper.Connection.prepareStatement(Connection.java:482) at fuego.jdbc.FaultTolerantConnection.prepareStatement(FaultTolerantConnection.java:541) at fuego.server.persistence.jdbc.JdbcServerActivityPersMgr.insertInstanceEvent(JdbcServerActivityPersMgr.java:913) at fuego.server.persistence.Persistence.storeInstanceEvent(Persistence.java:944) at fuego.server.execution.EngineExecutionContext.persistEvents
    So can we use such a big comparison on OBPM 10GR3. If yes, how?

    Don't use ASSOC Arrays. Use SETs.
    Also increase the JTA timeout in Weblogic to like say 600 seconds.

  • Using array as a dataprovider for combobox

    Hi folks, I would apreciate some help.
    I have a multi dimentional array as per
    _dbNames[0]=["Initialize User","","",""];
    How can assign an array like this as a dataprovider to a
    combobox using actionscript 3?
    Thanks for for the help!!

    Hey Jarno, 
    I did some playing around with this (sorry for the delay) and another workaround we can use is adding an Always Copy to the array before passing it into the Script Node. This will allow you to continue using Double precision arrays instead of going to Singles.
    It looks like there is an issue with the array copy that is passed into the SubVI through the terminal, but we can get around it by making a new copy that the Script Node can properly work with. 
    Tim A.
    National Instruments

  • Display array contents & prompt user for process priority

    Hi, i need help developing an interface.
    I have an array which contains a complete list of models available at my company. Now, i want to create an interface where the contents are displayed and user is able enter numbers to select the models he/she wants to run and the process priority.
    eg: The array contains models A to Z. The user is able to select models D, A, G and B and instruct the program to process them at the same sequence.
    How do i acheive this in Labview?
    I'm very poor at designing interface, can someone point me to any literature and tutorials in developing frontpanel interface in Labview?
    Thank you.

    Hey, I have done something similar to this in the past.  The way I did it was by using a listbox.  I had buttons that the user would select to tell me what to do and how to modify the listbox contents.  For example, in your case, I would have an Edit button.  When the user selects the Model and hits Edit, I would pop up a screen asking him which process he would like to assign to the model.  Then I would check for errors and if none existed, I would update the listbox contents with the new information.
    Let me know if this helps or if I should provide more explantation.
    Thanks!
    Dan
    Daniel Eaton
    National Instruments
    Systems Engineering
    Embedded and Industrial Control

  • Building array within 2 nested fors and 2 nested cases

    Hi all,
    I can't seem to figure out why one of my arrays keeps getting reset.  What I need to do is disassemble my clusters one at a time check for an node address then packet and decode the hex data.  Data decodes will be different for every node.  When a node is decoded, I need to add that data to an array dedicated to that node.  When the entire cluster array is processed, the data will be dumped to different Excel sheets.  One sheet for each node on the system. This is a simplified version of a much larger program that will handle many nodes and lots of data.  Any help would be appreciated.
    --Mark
    Attachments:
    Building an Array 2 fors 2 case.vi ‏19 KB

    Your tunnels on the inner loop need to be shift registers as well.

  • How I average data with 78,74,73 and 55 points respectively and end up with an array of 78 points for the average?

    Hi
    As the questions states, how do I average data with 78,74,73 and 55 points respectively and obtain an array of 78 points? 
    When I use the plus vi, Labview somehow produces an array of 55 points when I do the average (see attached vi).
    I have been unlucky in trying to get good results.
    Can anyone help?
    Thank you.
    Attachments:
    average4.vi ‏40 KB

    The add function is polymorphic. It accepts arrays as well as numerics, but you need to understand one thing about array operations in LV. Operations performed on arrays of different sizes will always (I think) work based on the smallest array. For example, if you auto index 2 arrays of different sizes into a for loop, the number of times the loop will run will be the size of the small array. The same is true here - when you wire 2 arrays of different sizes to the add function, only the first N elements of the larger array get processed. The rest are dumped. That's why you get 55 elements.
    Attached is a modification of your VI which shows 2 things:
    The bottom part is your algorithm, only cleaned up. Note how much easier it would be to read now. You should always write clean code. Also, note that I have changed the representation on some of the data from DBL to I32. This is because this is the representation the array function work with and your code had the DBLs coerced for no reason.
    The top part is a different algorithm which should do what you want. Note that like Mike said, the arrays with smaller sizes will have 0s appended at the end, so if you want to avoid that, you will have to modify the last part, where the averaging is done and only divide those columns which are long enough.
    To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
    Try to take over the world!
    Attachments:
    average4MOD.vi ‏63 KB

Maybe you are looking for