2D array output in a loop

Hello,
I need output data (several array string) from FOR-loop to 2D array. I use Replace array subset inside the loop (after array initialize). Output works (I see each step right string in its right place), But each next loop clear all previous strings to 0 0 0 . Finally stay only the last string in result array (see fig). Output to file works perfectly.
Similarly, no result outside of loop. 
WHY?
I'm beginner...
Solved!
Go to Solution.

Hi zazra,
But outside Out_array 2 and Out_array are empty (grey zero fields). 
THINK DATAFLOW!
Those two array indicators stay empty UNTIL the FOR loop finishes!
How to use out_array 4 - data outside the loop?
Either finish the FOR loop - or use a local variable (as easiest, but not the only solution)…
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome

Similar Messages

  • How to output last 4 arrays from a For Loop?

    Hi People,
    I am almost at the end of my tether. I really hope someone could please help me.
    Any input would be welcome. VI attached.
    VI explanation:
    I initialize an array.
    The random number generator simulates my camera input.
    Depending on which iteration it is, the data is added into one of four output arrays.
    'x-y*floor(x/y)' gives a remainder value of 0, 1, 2 or 3.
    'Case Selector' just adds 1 to 'x-y*floor(x/y)' to get case 1, 2, 3 or 4.
    Shots 1, 5, 9 etc are added to Array 1 (Case 1).
    Shots 2, 6, 10 etc are added to Array 2 (Case 2).
    Shots 3, 7, 11 etc are added to Array 3 (Case 3).
    Shots 4, 8, 12 etc are added to Array 4 (Case 4).
    Averaged Output displays the averaged value i.e. the total value divided by the number of shots saved in that array ('Set (IQ+1)').
    My problems are:
    1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
    Where should I place my file save diagram disable so that it does this?
    Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)
    Putting it outside the main For Loop with auto-indexing off gives me only the last set of data. (I need the output for 4 Arrays, not just the last run)
    Putting it inside the main For Loop (as shown) gives me the same number of files as number of iterations. (Again not feasible due to large number of files that will be generated and slow camera capture)
    For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
    2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
    3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
    I am using Labview 2010.
    Thanks so much,
    Jaslyn
    Solved!
    Go to Solution.
    Attachments:
    Help Understanding Arrays and file paths (10).vi ‏26 KB

    Thanks so much Lennard!!
    Hi JKSH,
    I've been busy trying to complete the dang code, but for completeness so that other users can learn too, I shall answer your queries. Thanks for looking in.
    First, what do you mean by "add"? Your code in your case strcuture sums your input values, so your array size doesn't change. However, you also said "Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)" -- it sounds like you are expecting an array with thousands of elements. So, what should "Output Array N" look like?
    Ans: Output Array N should be a 4x4 array of the summation of all the numbers generated during every 4th iteration.
    i.e. if random number 1=1, random number 2=2, etc, And 'No of iterations' is 12,
    Output Array 1 should be 1+5+9:
    15 15 15 15
    15 15 15 15
    15 15 15 15
    15 15 15 15
    (Note: Most of your arrays are 4x4, but in Case #2 you created 128x128. I prersume this is a typo?)
    Ans: Kind of, I'm using a 4x4 array of randomly generated numbers as an example but my actual data will be the 128x128 pixel output of a camera. And during actual experimentation, 'No of Iterations' will number in the thousands.
    Second, why do you add your "simulated camera input" to the "Initialized Array"? You can add it direcly to the previous output inside your case structure.
    Ans: See answer to question 3
    Third, have a look at shift registers: http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm. Use them instead of Feedback Nodes to make your code tidier.
    Ans: I did try.. But I can't seem to add shift registers to the case structure, only the for loops outside. Are you sure it can be done..?
    jaslyn wrote:
    1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
    Where should I place my file save diagram disable so that it does this?
    For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
    You will need to call "Write to Text File.vi" 4 times to write 4 files. So, you should finish your loop, then call this VI 4 times.
    Ans: How do I get it to extract the data from each of the 4 cases in my case structure?
    jaslyn wrote:
    2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
    You can create strings first, then convert them into paths: http://zone.ni.com/reference/en-XX/help/371361G-01/glang/string_to_path/
    Thanks
    jaslyn wrote:
    3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
    I'm not sure what you're asking; can you please clarify what you mean by "avoid using Memory Manager"? But anyway, you've actually initialized FIVE arrays: 1 outside the loop, and 1 inside each case.
    I've read that to avoid fluctuations in memory usage, it is a good idea to initialize arrays to their expected size before the start of data collection. That was just what I was trying to do.

  • How to get a value from an array in a nested loop

    Hi
    I have an array inside a four loop. The for loop (it is supposed to run 4 times) is further inside a while loop. The array consists of four elements and the values each of these elements are fed before running the program. To receive the values of each of these elements one by one outside the for loop, I am using the function index array. To receive all the values one by one, I created a shift register and wired the output of the index arrray to it. The problem is that instead of receiving all the values one by one, I am receiving only the value in the fourth
    element of the array...Can someone please help me..

    The attached file is my program.
    Attachments:
    Value from array.vi ‏25 KB

  • LabVIEW 6.1 If For Loop count terminal is zero then value going through the loop is not passed on to the output of the loop

    Hello, one of our customers just encountered an execution error in a vi running under LabVIEW 6.1, which doesn't exist under LabVIEW 5.1 or 6.01. I have a simple vi that has two encapsulated For Loops. Two string arrays go in, one goes out of the outer loop. Inside the outer loop the first array is indexed. The string which results from this indexing is compared with all other strings from the second string array in the inner loop. If it matches one of the strings of the second array, it is not outputted, otherwise this string goes through the inner For Loop to the output of the inner loop and from there to the output of the outer loop. The count
    terminal of the outer/inner loop is connected to the Array Size of the first/second string array. If the second array is empty, that means that the element in test from the first arry cannot match anything from the second array, so the element in test is send to the output of the inner loop and from there to the output of the outer loop. This works fine in LabVIEW 5.1 and 6.01, but NOT in LabVIEW 6.1. In LabVIEW 6.1 the inner loop is never executed if the count value is zero (which is correct), but the data line running through the loop is not executed either, which is different to what LabVIEW 5.1 and 6.01 do. There, the input string is sent to the output of the inner loop correctly even if the loop counter is zero. The solution is easy - I just have to connect the output of the outer loop to the data line BEFORE it enters the inner loop. But: I don't know if this is a LabVIEW 6.1 bug or if it is supposed to be a feature, but it brings some incompatibility in programming between the
    different LabVIEW versions.
    Best regards,
    Gabsi

    Hi,
    When a for-loop runs zero times, all outputs are 'undefined' (and should
    be).
    Besides, how would LV know what the output of a not executed routine should
    be?
    It might be handled differently in LV5 and LV6, which is unfortunate. In
    both cases, the result is undefined.
    It's not a bug. It's just something that should be avoided in any LV
    version.
    > The solution is easy - I just have to connect the
    > output of the outer loop to the data line BEFORE it enters the inner
    > loop. But: I don't know if this is a LabVIEW 6.1 bug or if it is
    In some cases this does the trick. But if the data is changed in the inner
    loop, this will effect the results if the N is not zero.
    Technically, I think the output in this construction is also 'undefined'.
    But LV handles this as expected / desired.
    Another solution is to use a shift register. If N is zero, the input is
    directly passed through to the output.
    Regards,
    Wiebe.
    "Gabs" wrote in message
    news:[email protected]...
    > LabVIEW 6.1 If For Loop count terminal is zero then value going
    > through the loop is not passed on to the output of the loop
    >
    > Hello, one of our customers just encountered an execution error in a
    > vi running under LabVIEW 6.1, which doesn't exist under LabVIEW 5.1 or
    > 6.01. I have a simple vi that has two encapsulated For Loops. Two
    > string arrays go in, one goes out of the outer loop. Inside the outer
    > loop the first array is indexed. The string which results from this
    > indexing is compared with all other strings from the second string
    > array in the inner loop. If it matches one of the strings of the
    > second array, it is not outputted, otherwise this string goes through
    > the inner For Loop to the output of the inner loop and from there to
    > the output of the outer loop. The count terminal of the outer/inner
    > loop is connected to the Array Size of the first/second string array.
    > If the second array is empty, that means that the element in test from
    > the first arry cannot match anything from the second array, so the
    > element in test is send to the output of the inner loop and from there
    > to the output of the outer loop. This works fine in LabVIEW 5.1 and
    > 6.01, but NOT in LabVIEW 6.1. In LabVIEW 6.1 the inner loop is never
    > executed if the count value is zero (which is correct), but the data
    > line running through the loop is not executed either, which is
    > different to what LabVIEW 5.1 and 6.01 do. There, the input string is
    > sent to the output of the inner loop correctly even if the loop
    > counter is zero. The solution is easy - I just have to connect the
    > output of the outer loop to the data line BEFORE it enters the inner
    > loop. But: I don't know if this is a LabVIEW 6.1 bug or if it is
    > supposed to be a feature, but it brings some incompatibility in
    > programming between the different LabVIEW versions.
    > Best regards,
    > Gabsi

  • 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

  • New to Graphics, trying to display array output in a single window

    I am trying to figure out how to use the GUI components of JAVA.
    What I am trying to do is take my packaged array output and list it in a single window. All that ever prints is last array data set. The last keeps overwritting the previous. How do I keep the previous data shown while listing the next in the array?
    Below are my three classes. The Frame Class is the class containing the display method. It is called near the bottom of the Product Class.
    Product.java
    // Inventory Program Part 4
    /* This program will store multiple entries
    for office supplies, give the inventory value,
    sort the data by Product Name,
    and output the results using a GUI */
    import javax.swing.text.JTextComponent;
    import javax.swing.JLabel;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JOptionPane; //Uses class JOptionPane
    import java.util.Scanner; //Uses class Scanner
    import java.util.Arrays; //Uses class Arrays
    public class Product
         private String productBrand[]; // Declares the array
         public void setProductBrand( String brand[] ) // Declare setProductBrand method
              productBrand = brand; // stores the productbrand
         } // End setProductBrand method
         public String getProductBrand( int counter )  // Declares getProductBrand method
              return productBrand[ counter ]; // Returns data using counter to define the element
         } // End method getProductBrand
         public double restockingFee( double value ) // Declares restocking Fee method
              double fee = 0; // Declares variable fee
              fee = value * 0.05; // Calculates the sum of values
              return fee;  // Returns the restocking fee
         } // End method restockingFee     
         public String inventoryValue( double value[] , int number, String name[] ) // Declares inventoryValue method
              OfficeSupplies myOfficeSupplies = new OfficeSupplies();  //Creates OfficeSupplies Object
              Product myProduct = new Product();
              double total = 0; // Declares variable total
              for ( int counter = 0; counter < number ; counter++ )
                   total += ( value[ counter ] + myProduct.restockingFee( value[ counter ] ) ); // Calculates the sum of values
                        return String.format( "%s$%.2f", "Total Inventory Value: " , total );  // Returns the total value
         } // End method inventoryValue
         // main method begins execution
         public static void main( String args[] )
              Scanner input = new Scanner( System.in ); //Creates Scanner object to input from command window
              Product myProduct = new Product(); //Creates Product object
              OfficeSupplies myOfficeSupplies = new OfficeSupplies();  //Creates OfficeSupplies Object          
              //Prompt for maxNumber using JOptionPane
              String stringMaxNumber =
                   JOptionPane.showInputDialog( "Enter the number of products you wish to enter" );
              int maxNumber = Integer.parseInt( stringMaxNumber );     
              String prodName[] = new String[ maxNumber ]; // Declares prodName array
              int numberUnits[] = new int[ maxNumber ]; // Declares maxNumber array          
              float unitPrice[] = new float[ maxNumber ]; // Declares unitPrice array
              double value[] = new double[ maxNumber ]; // Declares value array
              String brand[] = new String [ maxNumber ]; // Declares brand array
              String stringNumberUnits[] = new String [ maxNumber]; // Declares array
              String stringUnitPrice[] = new String [ maxNumber ]; // Declares array
              int productNumber[] = new int[ maxNumber ]; // Declares array
              for ( int counter = 0; counter < maxNumber; counter++ ) // For loop for the number of products to enter
                   productNumber[ counter ] = counter;
                   myOfficeSupplies.setProductNumber( productNumber ); // Sends the Product name to method setProductNumber                         
                   //Prompt for product name using JOptionPane
                   prodName[ counter ] =
                        JOptionPane.showInputDialog( "Enter the Product Name" );
                   myOfficeSupplies.setProductName( prodName ); // Sends the Product name to method setProductName
                   //Prompt for brand name using JOptionPane
                   brand[ counter ] =
                        JOptionPane.showInputDialog( "Enter the Brand name of the Product" );
                   myProduct.setProductBrand( brand ); // Sends the Brand name to method setProductBrand
                   //Prompt for number of units using JOptionPane
                   stringNumberUnits[ counter ] =
                        JOptionPane.showInputDialog( "Enter the Number of Units" );
                   numberUnits[ counter ] = Integer.parseInt( stringNumberUnits[ counter ] );
                   myOfficeSupplies.setNumberUnits( numberUnits ); // Sends the Number Units to the method setNumberUnits
                   //Prompt for unit price using JOptionPane
                   stringUnitPrice[ counter ] =
                        JOptionPane.showInputDialog( "Enter the Unit Price" );
                   unitPrice[ counter ] = Float.parseFloat( stringUnitPrice[ counter ]);
                   myOfficeSupplies.setUnitPrice( unitPrice ); // Sends the Unit Price to the method setUnitPrice
                   value[ counter ] = numberUnits[ counter ] * unitPrice[ counter ]; // Calculates value for each item
                   myOfficeSupplies.setProductValue( value ); // Sends the product value to the method setProductValue
              Arrays.sort( prodName, String.CASE_INSENSITIVE_ORDER ); // Calls method sort from Class Arrays
                   Frame myFrame = new Frame();
                   myFrame.displayData( myProduct, myOfficeSupplies, maxNumber );
              // Outputs Total Inventory Value using a message dialog box
              JOptionPane.showMessageDialog( null, myProduct.inventoryValue( value, maxNumber, prodName ),
                   "Total Inventory Value", JOptionPane.PLAIN_MESSAGE );
         } // End method main
    } // end class ProductOfficeSupplies.java ----> This is the data container
    // Inventory Program Part 4
    /* Stores the array values */
    public class OfficeSupplies // Declaration for class Payroll
         private int productNumber[];
         public void setProductNumber( int number[] ) // Declare setProductNumber method
              productNumber = number; // stores the product number
         } // End setProductNumber method
         public int getProductNumber( int counter )  // Declares getProductNumber method
              return productNumber[ counter ];
         } // End method getProductNumber
         private String productName[];
         public void setProductName( String name[] ) // Declare setProductName method
              productName = name; // stores the Product name
         } // End setProductName method
         public String getProductName( int counter )  // Declares getProductName method
              return productName[ counter ];
         } // End method getProductName
         private int numberUnits[];
         public void setNumberUnits( int units[] ) // Declare setNumberUnits method
              numberUnits = units; // stores the number of units
         } // End setNumberUnits method
         public int getNumberUnits( int counter )  // Declares getNumberUnits method
              return numberUnits[ counter ];
         } // End method getNumberUnits
         private float unitPrice[];
         public void setUnitPrice( float price[] ) // Declare setUnitPrice method
              unitPrice = price; // stores the unit price
         } // End setUnitPrice method
         public float getUnitPrice( int counter )  // Declares getUnitPrice method
              return unitPrice [ counter ];
         } // End method getUnitPrice
         private double productValue[];
         public void setProductValue( double value[] ) // Declare setProductValue method
              productValue = value; // stores the product value
         } // End setProductValue method
         public double getProductValue( int counter )  // Declares getProductValue method
              return productValue[ counter ];
         } // End method getProductValue
    } // end class OfficeSuppliesFrame.java ------> Contains the display method
    import java.awt.Color;
    import javax.swing.text.JTextComponent;
    import javax.swing.JLabel;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JOptionPane; //Uses class JOptionPane
    public class Frame extends JFrame
         public Frame() //Method declaration
              super( "Products" );
         } // end frame constructor
         public void displayData( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
              //Here I attempted to use an array to output all of the array data in a single window
    //          JTextArea myTextArea[] = new JTextArea[ maxNumber ]; // Declares myTextArea array to display output
              JTextArea myTextArea = new JTextArea(); // textarea to display output
              // For loop to display data array in a single Window
              for ( int counter = 0; counter < maxNumber; counter++ )  // Loop for displaying each product
    //               myTextArea[ counter ].setText( packageData( myProduct, myOfficeSupplies, counter ) + "\n" );
    //                add( myTextArea[ counter ] ); // add textarea to JFrame
                   myTextArea.setText( packageData( myProduct, myOfficeSupplies, counter ) + "\n" );
                   add( myTextArea ); // add textarea to JFrame
              } // End For Loop
              setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              setSize( 450, maxNumber*400 ); // set frame size
              setVisible( true ); // display frame
         public String packageData( Product myProduct, OfficeSupplies myOfficeSupplies, int counter ) // Method for formatting output
              return String.format( "%s: %d\n%s: %s\n%s: %s\n%s: %s\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f",
              "Product Number", myOfficeSupplies.getProductNumber( counter ),
              "Product Name", myOfficeSupplies.getProductName( counter ),
              "Product Brand",myProduct.getProductBrand( counter ),
              "Number of Units in stock", myOfficeSupplies.getNumberUnits( counter ),
              "Price per Unit", myOfficeSupplies.getUnitPrice( counter ),
              "Total Value of Item in Stock is", myOfficeSupplies.getProductValue( counter ),
              "Restock charge this product is", myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ),
              "Total Value of Inventory plus restocking fee", myOfficeSupplies.getProductValue( counter )+
                   myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ) );
         } // end method packageData
    }

    Lets pretend that your assignment was to manage a list of employees of a store, and that each employee is identified by their name, position, and hourly wage. If you created a program along the lines of your current product program, I picture you creating three separate ArrayLists (or arrays), one for each variable, something like this:
    import java.util.ArrayList;
    public class MyEmployees1
        private ArrayList<String> names = new ArrayList<String>();
        private ArrayList<String> positions = new ArrayList<String>();
        private ArrayList<Double> hourlyWages = new ArrayList<Double>();
        public void add(String name, String position, double wage)
            names.add(name);
            positions.add( position);
            hourlyWages.add(wage);
        public void removed()
            // TODO: I am nervous about trying to manage this!
        //.......... more
    }This program tries to manage three separate parallel arrays (arraylists actually). They are parallel because the 3rd item in the names list corresponds to the 3rd item in the positions list and also the hourlywages list. If I wanted to delete data, I'd have to be very careful to delete the correct item in all three lists. If I tried to sort one list, I'd have to sort the other two in exactly the same way. It is extremely easy to mess this sort of program up.
    Now lets look at a different approach. Say we created a MyEmployee class that contains the employee's name, position, and wage, along with the appropriate constructors, getters, setters, toString method, etc... something like so:
    import java.text.NumberFormat;
    public class MyEmployee
        private String name;
        private String position;
        private double hourlyWage;
        public MyEmployee(String name, String position, double hourlyWage)
            this.name = name;
            this.position = position;
            this.hourlyWage = hourlyWage;
        public String getName()
            return name;
        public String getPosition()
            return position;
        public double getHourlyWage()
            return hourlyWage;
        public String toString()
            // don't worry about these methods here.  They're just to make the output look nice
            NumberFormat currency = NumberFormat.getCurrencyInstance();
            return String.format("Name: %-15s    Position: %-15s    Wage: %s",
                    name, position, currency.format(hourlyWage));
    }Now I can create a MyEmployees2 class that holds a single list of MyEmployee objects, like so:
    import java.util.ArrayList;
    public class MyEmployees2
        private ArrayList<MyEmployee> employeeList = new ArrayList<MyEmployee>();
        public boolean add(MyEmployee employee)
            return employeeList.add(employee);
        public boolean remove(MyEmployee employee)
            return employeeList.remove(employee);
        public void display()
            for (MyEmployee employee : employeeList)
                System.out.println(employee);
        public static void main(String[] args)
            MyEmployees2 empl2 = new MyEmployees2();
            empl2.add(new MyEmployee("John Smith", "Salesman", 20));
            empl2.add(new MyEmployee("Jane Smyth", "Salesman", 25));
            empl2.add(new MyEmployee("Fred Flinstone", "Janitor", 15));
            empl2.add(new MyEmployee("Barney Rubble", "Supervisor", 35));
            empl2.add(new MyEmployee("Mr. Spacely", "The Big Boss", 45));
            empl2.display();
    }Now if I want to add an Employee, I only add to one list. Same if I want to remove, only one list, and of course, the same for sorting. It is much safer and easier to do things this way. Make sense?

  • Array output from formula node

    How to get an array output from the formula node.I am trying to use a for loop inside the formula node and want an array output.

    You cannot place a For or While Loop inside the formula node.
    Here is what the Help Description says about the syntax inside the Formula Node:
    Formula Node
    Evaluates mathematical formulas and expressions similar to C on the block diagram. The following built-in functions are allowed in formulas: abs, acos, acosh, asin, asinh, atan, atan2, atanh, ceil, cos, cosh, cot, csc, exp, expm1, floor, getexp, getman, int, intrz, ln, lnp1, log, log2, max, min, mod, pow, rand, rem, sec, sign, sin, sinc, sinh, sizeOfDim, sqrt, tan, tanh. There are some differences between the parser in the Mathematics VIs and the Formula Node.
     Place on the block diagram
     Find on the Functions palette
    Refer to Creating Formula Nodes and Formula Node Syntax for more information about the Formula Node and the Formula Node syntax.
    Note  The Formula Node accepts only the period (.) as a decimal separator. The node does not recognize localized decimal separators.
    <SCRIPT type=text/javascript>if (typeof(writeVarRefs)=="function"){writeVarRefs("763");}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvrthelp763) != "undefined"){document.writeln(lvrthelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvfpga763) != "undefined"){document.writeln(lvfpga763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvemb763) != "undefined"){document.writeln(lvemb763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvpdahelp763) != "undefined"){document.writeln(lvpdahelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvtpchelp763) != "undefined"){document.writeln(lvtpchelp763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvblackfin763) != "undefined"){document.writeln(lvblackfin763)}</SCRIPT>
    <SCRIPT type=text/javascript> if(typeof(lvdsp763) != "undefined"){document.writeln(lvdsp763)}</SCRIPT>
    Example
    Refer to the Create Function with Formula Node VI in the labview\examples\general\structs.llb for an example of using the Formula Node.

  • How do I get an array output on a Formula Node?

    My problem is simply that I cannot figure out how to get an output on a Formula Node to be an array. Documentation states that "you must declare local arrays and output arrays in the Formula Node" but doesn't say anything more than than. Attempts to put something like "float32 out[100];" for an array output called "out" fail.
    If anybody knows how you can do this or even knows if it is possible I would appriciate your help.
    Thanks,
    Naveen

    I found a typo in the formula node I was doing that was making the output not be an array. I don't think I was getting the error before but I was going to put together an example VI to attach here and I found it. So, thanks for your help even tho it was a stupid little mistake on my part.

  • Array output from formula node with input variable as array size

    Hi,
    I have created a formula node with an array output called al, but I get an error "you have connected a scalar type to an array with that type".
    I declare the output as follows..
    float64 al[len_as];
    where len_as is an scalar input to the formula node.
    It only works when I put a number as.
    float64 al[5];
    ,but I don't know beforehand how many elements I need, so I cannot use this.
    Please help! This is so stupid.
    Thanks

    Don't define your array in your formula node.
    Initialize the array as the size you want and pass it in as an input into the formula node.
    Are you sure you even need to use a formula node?  Can you implement your formula using all native LabVIEW functions?
    Message Edited by Ravens Fan on 10-07-2009 11:51 PM
    Attachments:
    Example_VI_BD.png ‏3 KB

  • Output strings from loop into one string

    im trying my best to explain my problem so ber in mind:)
    hey having a bit of trouble with outputing strings from loop
    example
    i typed ab into the textbox
    the output should be 12
    but since it is in a loop it would only output the last string and in this case is 2
    im trying to get both strings from the loop and output strings from loop into one string.
    here is some of my code to understand my problem
    // characters a to f
         char[] charword = {'a','b','c','d','e','f'};
         String charchange ;
      // get text from password textbox
                          stringpassword = passwordTextbox.getText();
                          try {
                          // loop to show password length
                          for ( int i = 0; i < stringpassword.length(); i++ ){
                          // loop to go through alfabet     
                          for (int it = 0; it < charword.length; it++){
                             // if char equals stringwords
                               if (stringpassword.charAt(i) == charword[it]){
                                    System.out.print("it worked");
                                    // change characters start with a
                                    if (charword[it] == 'a'){
                                         charchange = "1";
                                    // change to 2
                                    if (charword[it] == 'b'){
                                         charchange = "2";
                                        }

    Not sure how you are displaying the result but you could display each value as soon as you find it.
    if (charword[it] == 'a'){
        System.out.print("1");
    }If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
    if (charword[it] == 'a'){
        charchange += "1";
    }

  • 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

  • Creating an array in a 'for' loop (resetting loop count)

    Hi,
    I am trying to integrate an acceleration signal coming from a CRIO analogue input to obtain the speed and then further integrate to get the displacement of a vibration system.
    I understand that in order to perform the integration, an array has to be fed in. My problem is that I could not buffer the signal in a buffer block as I couldn't find any buffer blocks. so I decided to create my an array of data using a 'for' loop. The 'for' loop nests inside a timed loop. The problem that I got stuck at is how to reset the 'for' loop in order to refill the buffer again at every iteration of the outer timed loop.
    I have attached the code if that helps. Note that I am using labview 2013.
    I would be gratefull if someone who had encountered a similar issue before can help me.
    Regards
    Ali
    Solved!
    Go to Solution.
    Attachments:
    acc_test.vi ‏42 KB

    Dear Altenbach,
    Many thanks for your reply.
    I need to make it clear that I have not had enough hands-on with labview, I have only used it for sometime in the past and now I have to in order to perform some active damping on a 50Hz running machine. I must stress the fact that what i find more intuitive to do in a different programming language (matlab or C) is not as straightforward in labview. so please bear with me if my code has basic mistakes .
    All what i am trying to do is obtain the speed and position from an acclerometer signal. unfortunately i dont have a position sensor so i have to measure acceleration then perform time integrations in order to obtain the speed and position respectively. I am using a compact Rio (later in FPGA mode) to take physical measurements of acceleration from the vibratory machine and where i managed to do this bit successfully. when it came to performing the integration, i had to create an array inside my timed loop since i couldn't find a buffer block. I implemented a 'for' loop inside a timed loop in order to build the array. however i got stuck at resetting the count of the 'for' loop in order to refill the array with new values at every new iteration of the outer timed loop. unfortunately, even a sensible answer has been suggested before, i dont seem to have been capable of doing it yet. I really spent all my day trying to figure a way out but not achieved it yet, nevertheless I have learnt many many things by playing around.
    I would be gratefull if you could comment on a possible way of doing what i am trying to do.
    Kind Regards
    Ali

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

  • 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

  • Sorting an array of numbers with loops

    Hi, i'm looking for a way to sort an array or numbers with loops.
    my array looks like this. int[] numbers = {5,2,7,9,1}
    i know how to use the "sort" method and i want to do it without the sort method, but i am not very clear on the logic behind it.
    by the end it should look like this, {1,2,5,7,9}
    i know 2 loops are used, can you please give me a logic to work with.
    i have started the loops but what to do inside???
    int temp;
    for (int i=0; i<numbers.length; i++){
    for (int j=1; j<numbers; j++){
    if (numbers<numbers[j])
    temp = numbers[i];
    Any suggestions i will be thankful for.
    thank you.

    fly wrote:
    no not really a homework question.. i want to improve my logic because it is very poor at the moment.. but i'm sure someone knows how to sort an array with loops only.Yes, we do know how to do it, I once wrote a heapsort in assembly code, as a real work project. But you rarely get a project like that the good ones were all done years ago.
    All the algorithms I suggested you look at use loops. the simplest and slowest is the bubble sort. This one runs by comparing values and swapping their locations, the wikipedia article http://en.wikipedia.org/wiki/Bubble_sort has the algorithm.

Maybe you are looking for

  • Numbers 09 (Rel. 2.1(436)) extremely slow under Lion

    I just gave Numbers a try with a relatively low complex mortgage calculation - 13 columns, 200 rows - simple formulas (if ... then ... else, difference in dates, simple multiplications). Numbers is extremely slow - whenever something is changed in th

  • HTTP request isrequestsessionIdvalid()  function problem

    Hi, To check the expiration of the HTTPSession , i have used in my Controller servlet , a check as: if (!isRequestSessionIdValid()){ out.println("Session has expired!!!") however the above piece creates problem,As I type the URL and hit ENTER the con

  • When starting webcenter domain, how not to enter userid and password?

    Dear All, I followed this link http://yonaweb.be/start_webcenter_domain in installing my webcenter domain and I was successful in setting my own webcenter and busy exploring the webcenter spaces. My only concern is that when I am starting my webcente

  • Hp P2015d can't print after upgraded to 10.5

    i can't use my network printer after upgrade to 10.5 from 10.4, anyone can help?? printer is P2015d

  • Putting operating system on ipod

    Is there a way to put OSX on my ipod and run it off my ipod? If so, how will the performance be? Much slower than a regular hard drive or the same? Also, can I do it without deleting the music that I have on there already and still use it as a simult