Possible index combinations in 2D array - more Math Question than LabView???

Hi All,
I accidently submitted the first post.. please disregard the previous one.
I am struggling with this problem. Please HELP!!!
I have an array of numbers:
Set1  50     62    73    82       91     96   100
Set2  43     78    146  186     230   255
Set3  0.25  2      6     12       20
Set4  5       50    500   2000  8000
Set5  5       50    500   2000  8000
I need to create all possible combinations for Set1 through Set5.
Example:
{50, 43, 0.25, 5, 5}
{50, 43, 0.25, 5, 50}
{50, 43, 0.25, 5, 500}
{50, 43, 0.25, 5, 2000}
{50, 43, 0.25, 5, 8000}
{50, 43, 0.25, 5, 5}
{50, 43, 0.25, 50, 5}
{50, 43, 0.25, 500, 5}
{50, 43, 0.25, 2000, 5}
{50, 43, 0.25, 8000, 5}
{50, 43, 0.25, 5, 5}
{50, 43, 2, 5, 5}
{50, 43, 6, 5, 5}
{50, 43, 12, 5, 5}
{50, 43, 20, 5, 5}
and so on....
I just can't figure out how to loop this through to go through all possible combinations of the 5 sets. (
Looking forward to your suggestions and help.
Thanks,
Mim
Message Edited by Mim on 11-17-2005 11:26 AM

You have to have 5 nested loops.
Let's call your COLUMNS A-E and your ROWS 0-4:
A0 B0 C0 D0 E0
A1 B1 C1 D1 E1
A2 B2 C2 D2 E2
A3 B3 C3 D3 E3
A4 B4 C4 D4 E5
Extract all the COLUMNS.
Take COLUMN A and autoindex it on the first (outside) loop:
For i = 0 to 4
Ax = A[i]
Pass Column B THROUGH the first FOR loop and autoindex it on the second loop:
For i = 0 to 4
Bx = B[i] // autoindexing will do this for you
Pass Column C THROUGH the first and second FOR loop and autoindex it on the third loop:
For i = 0 to 4
Cx = C[i] // autoindexing will do this for you
and so on:
For i = 0 to 4
Dx = D[i] // autoindexing will do this for you
For i = 0 to 4
Ex = E[i] // autoindexing will do this for you
Assemble Ax, Bx, Cx, Dx and Ex into a set and do with it what you want.
Just do five nested loops and remember to autoindex A on the outside loop, B on the 2nd, C on the 3rd, D on the 4th, and E on the inside loop.
I think you will get 5^5 combinations.Message Edited by CoastalMaineBird on 11-17-2005 10:44 AM
Message Edited by CoastalMaineBird on 11-17-2005 10:45 AM
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks

Similar Messages

  • Possible index combinatio​ns in 2D array - more Math Question than LabView???

    Hi All,
    I am struggling with this problem:
    I have a 2D array
    50   62 73 82 91 96 100
    43 78 146 186 230 255
    0.25 2 6 12 20
    5 50 500 2000 8000
    5 50 500 2000 8000

    As a general rule of thumb, given a 2-D array with a set number X and Y the unique number of index combinations will be simply X * Y.  So, for example, a 5 x 5 array will have 25 unique combinations.  [1][1], [1][2], [1][3], ... , [4][5], [5][5].

  • Easiest way to sum all possible (different) combinations in an array?

    Hey guys, 
    Say I have an array of sorted values (of attenuation), I want to generate an array of all possible sums of those values, sort it, then refer to it as a list of all possible attenuation values (lets say theyre bits on a discrete digital attenuator).  I will try to show you an example of what I mean with letters:
    Array of attens: [a, b, c, d]
    I want an array like this: [a+b,  a+c,  a+d,  a+b+c,  a+b+d,  a+c+d,  b+c,  b+d,  b+c+d]... I hope I'm not missing any combos here...
    I'm attaching my attempt at this idea but there's something missing I think, I am doing something wrong...
    Thanks for any ideas or help.
    Solved!
    Go to Solution.
    Attachments:
    Sum all possible combos.vi ‏18 KB

    Ben wrote:
    The challenge is getting all possible combos.
    Have you concidered looking at this as a variation on binary counting?
    The total number of combinations is 2^(NumberOfSettings) if you include "None".
    So generate a ramp from zero to the total number possible.
    Convert each number to a boolean array and then use the boolean to determine if its corresponding value gets add into the total.
    After processing all of the values from the ramp the final array should be in ascending order.
    I hope that outline helps,
    Ben
    Ben, that is actually quite brilliantly simple.  I like it.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Combining 2 grahics or more into one

    Using AS3 code, is it possible to combine 2 graphics or more into one?
    Example : combining a rectangle and a triangle to make a nice arrow?

    Do you know anything about AS3 drawing API - I guess this is what you need to use:
    This is an example of how one can draw rectangle:
    var sp:Sprite = new Sprite();
    sp.graphics.beginFill(0xff0000);
    sp.graphics.drawRect(0, 0, 100,200);
    sp.graphics.endFill();
    addChild(sp);
    Read:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/Graphics.html
    And this:
    http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Liv eDocs_Parts&file=00000176.html

  • Is it possible to combine two or more different apple accounts to one account?

    Is it possible to combine two or more different apple accounts to one account?

    No, you can't combine accounts nor transfer content between accounts - content will remain tied to the account that downloaded it.

  • Printing every possible pair combination of elements in two arrays??

    Hi there,
    I'm trying to implement the problem of printing every possible pair combination of elements in two arrays. The pattern I have in mind is very simple, I just don't know how to implement it. Here's an example:
    g[3] = {'A', 'B', 'C'}
    h[3] = {1, 2, 3}
    ...code...??
    Expected Output:
    A = 1
    B = 2
    C = 3
    A = 1
    B = 3
    C = 2
    A = 2
    B = 1
    C = 3
    A = 2
    B = 3
    C = 1
    A = 3
    B = 1
    C = 2
    A = 3
    B = 2
    C = 1
    The code should work for any array size, as long as both arrays are the same size. Anybody know how to code this??
    Cheers,
    Sean

    not a big fan of Java recursion, unless tail recursion, otherwise you are bound to have out of stack error. Here is some generic permutation method I wrote a while back:
    It is generic enough, should serve your purpose.
    * The method returns all permutations of given objects.  The input array is a two-dimensionary, with the 1st dimension being
    * the number of buckets (or distributions), and the 2nd dimension contains all possible items for each of the buckets.
    * When constructing the actual all permutations, the following logic is used:
    * take the following example:
    * 1    2    3
    * a    d    f
    * b    e    g
    * c
    * has 3 buckets (distributions): 1st one has 3 items, 2nd has 2 items and 3rd has 2 items as well.
    * All possible permutaions are:
    * a    d    f
    * a    d    g
    * a    e    f
    * a    e    g
    * b    d    f
    * b    d    g
    * b    e    f
    * b    e    g
    * c    d    f
    * c    d    g
    * c    e    f
    * c    e    g
    * You can see the pattern, every possiblity of 3rd bucket is repeated once, every possiblity of 2nd bucket is repeated twice,
    * and that of 1st is 4.  The number of repetition has a pattern to it, ie: the multiplication of permutation of all the
    * args after the current one.
    * Therefore: 1st bucket has 2*2 = 4 repetition, 2nd has 2*1 = 2 repetition while 3rd being the last one only has 1.
    * The method returns another two-dimensional array, with the 1st dimension represent the number of permutations, and the 2nd
    * dimension being the actual permutation.
    * Note that this method does not purposely filter out duplicated items in each of given buckets in the items, therefore, if
    * is any duplicates, then the output permutations will contain duplicates as well.  If filtering is needed, use
    * filterDuplicates(Obejct[][] items) first before calling this method.
    public static Object[][] returnPermutation(Object[][] items)
         int numberOfPermutations = 1;
         int i;
         int repeatNum = 1;
         int m = 0;
         for(i=0;i<items.length;i++)
              numberOfPermutations = numberOfPermutations * items.length;
         int[] dimension = {numberOfPermutations, items.length};
         Object[][] out = (Object[][])Array.newInstance(items.getClass().getComponentType().getComponentType(), dimension);
         for(i=(items.length-1);i>=0;i--)
              m = 0;
              while(m<numberOfPermutations)
                   for(int k=0;k<items[i].length;k++)
                        for(int l=0;l<repeatNum;l++)
                             out[m][i] = items[i][k];
                             m++;
              repeatNum = repeatNum*items[i].length;
         return out;
    /* This method will filter out any duplicate object in each bucket of the items
    public static Object[][] filterDuplicates(Object[][] items)
         int i;
         Class objectClassType = items.getClass().getComponentType().getComponentType();
         HashSet filter = new HashSet();
         int[] dimension = {items.length, 0};
         Object[][] out = (Object[][])Array.newInstance(objectClassType, dimension);
         for(i=0;i<items.length;i++)
              filter.addAll(Arrays.asList(items[i]));
              out[i] = filter.toArray((Object[])Array.newInstance(objectClassType, filter.size()));
              filter.clear();
         return out;

  • Is it possible to combine JOptionPanes

    Hi, i'm trying to write a cute program for my sister to help her with her math, no anything fancy.
    However, i was wondering weather it was possible to combine an Input JOptionPane and an Option JOption Pane, meaning it has a text area for an Input and buttons like cancel and stuff.
    Thanks in advanced for any answers.

    well, i read the link.. and got waaaayyy to confused.. moreover it did not show the example i needed. a specific example would be very welcome as i'm preety much a newbie in Java (going to the Uni only in 3 yrs) so if you could please explain it in more of a lamen terms, or give a code example, i'd be gratful. Thanks for the link tho, it was informative.

  • How to combine 3-D Array pages?

    I have a 3-D array of data and I’d like to combine all the pages into one table. Is there a way to do it?
    KowdTek
    LabVIEW 2009
    One Step At A Time, Maybe Two...
    Solved!
    Go to Solution.
    Attachments:
    Data.vi ‏8 KB

    KowdTek wrote:
    I want something like this.
    Here is one possibility. Since your 3D array has a variable number of empty rows on each page, a simple reshape alone will not be sufficient, you also need to eliminate empty rows.
    I don't know what kind of row order you want, but my solution gives a different order than your desired output. Still, this should get you started. You might need to sort the rows differently.
    There could be bugs, so modify as needed.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    DataResult.png ‏9 KB
    Data_ResultMOD.vi ‏12 KB

  • Is it possible to Combine photostream in iphoto?

    Hello,
    It woud be great if It is possible to combine more single photostreams into one iPhoto application.
    My wife and daughter have each their own iCloud account. But we would like That The photos come together in iPhoto without syncing with My iMac.
    Is this at the moment possible?
    Best Regards,
    Bart Collet

    I agree, this would be a great addition to iPhoto, for it to support multiple photo streams. Currently my work around is to have my iCloud account be the primary on my wife's iPhone with all features turned off excluding Photo Stream, and then her account is an additional iCloud/email account with all features turned on (except Photo Stream).
    One major downside to this is that all of her backups are going against my iCloud quota.
    You should submit iPhoto Feedback to request this feature/enhancement.
    http://www.apple.com/feedback/iphoto.html

  • Combining two StringBuffer array elements into a single array element

    I just need to know how to combine two stringBuffer array elements into one
    StringBuffer ciphertext [] = new StringBuffer[2];
              StringBuffer s0 = new StringBuffer("11011111111110001001101110110101");
              StringBuffer s1 = new StringBuffer("00010011001101000101011101111001");
              ciphertext[0] = s0;
              ciphertext[1] = s1;
              ciphertext[2] = ciphertext[0].append(ciphertext[1]);I get an array index out of bounds exception:2
    Thanks

    StringBuffer ciphertext [] = new StringBuffer[3];  // legal index values are: 0,1,2

  • Possible to Combine LR Slideshows??

    Is it possible to combine 2 or more slideshows that were created in LR.
    Each slideshow has different music and "opening and closing" slides.  I'd like to maintain these differences while stitching them together so that I can make one seemless video.
    My guess is that this isn't 'in the cards' for LR.  If that's true, can you recommend some other software option(s) where this can be done?
    I appreciate your help.
    Chris

    Proshow Gold or Proshow Producer are good for that sort of thing (although they aren't the cheapest pieces of software in the world!)
    Phil

  • Getting index of a string array based on user selection in a comboBox

    I'm not really sure how to phrase my questions, but here goes.
    I have created a string array that holds the values of a ComboBox. Based on which selection the user makes in the comboBox, I need the program to then perform particular calcualtions (based on their selection). I have tried using an ItemListener, but that doesn't seem to work. I've also tried using the ActionListener connected to the ComboBox, again...without results. I'm not sure what I'm looking for exactly, but I know what I want it to do, I'm just not finding the right way to do it. Can anyone help me figure this out?

    Here is my entire code. I'm completely confused at where to put the ActionListener or how to make it do what I want. Right now I just have it set up to display a simple message in the displayArea, just so that I could see if it was working. I think once I figure out how to get the right index from the ComboBox array, then I'll be able to add the code I need to perform the calcualtions...it's just getting to that step that's not going so well! Any help is appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.DecimalFormat;
    import java.lang.String;
    public class MortCalcSR5 extends JFrame implements ActionListener
         int term = 0;
         double principal = 0;
         double rate = 0;
         double monthlyPyment = 0;
         double interest = 0;
         String[] loanChoices = {" ", "7 years @ 5.35%", "15 years @ 5.5%", "30 years @ 5.75%"};
         //create panel for input
         JPanel inputPanel = new JPanel();
              JLabel mortAmtLabel = new JLabel("Mortgage Amount $");
              JTextField mortAmtField = new JTextField(15);
              JLabel loanSelectionLabel = new JLabel("Loan Selection");
              JComboBox loanSelection = new JComboBox(loanChoices);
              JTextField loanSelected = new JTextField(15);
         //create button panel
         JPanel buttonPanel = new JPanel();
              JButton calcButton = new JButton("Calculate");
              JButton clearButton = new JButton("Clear");
              JButton exitButton = new JButton("Exit");
         //create panel for payment information
         JPanel paymentPanel = new JPanel();
              JLabel paymentLabel = new JLabel("Monthly Payment $");
              JTextField paymentField = new JTextField(15);
         //create panel for text box information
         JPanel textPanel = new JPanel();
              JLabel numPaymentLabel = new JLabel("Payment #");
              JLabel balLabel = new JLabel("Balance");
              JLabel ytdPrincLabel = new JLabel("Principal");
              JLabel ytdIntLabel = new JLabel("Interest");
         //create payment for display area
         JPanel displayPanel = new JPanel(new FlowLayout());
              JTextArea displayArea = new JTextArea(10,30);
              JScrollPane scroll = new JScrollPane(displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
         public MortCalcSR5()
              //set size of GUI display
              setSize(400,450);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Container pane = getContentPane();
              JScrollPane scroll = new JScrollPane (displayArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
              FlowLayout layout = new FlowLayout(FlowLayout.LEFT);
              pane.setLayout(layout);
              //add components to the inputPanel
              GridLayout layout2 = new GridLayout(4,1);
              inputPanel.setLayout(layout2);
              inputPanel.add(mortAmtLabel);
              inputPanel.add(mortAmtField);
              mortAmtField.setText(" ");
              inputPanel.add(loanSelectionLabel);
              inputPanel.add(loanSelection);
              loanSelection.addActionListener(this);
              pane.add(inputPanel);
              //add components to buttonPanel
              FlowLayout layout3 = new FlowLayout(FlowLayout.CENTER, 10, 10);
              buttonPanel.setLayout(layout3);
              buttonPanel.add(calcButton);
              buttonPanel.add(clearButton);
              buttonPanel.add(exitButton);
              pane.add(buttonPanel);
              //add listeners to buttons
              calcButton.addActionListener(this);
              clearButton.addActionListener(this);
              exitButton.addActionListener(this);
              //add components to outputPanel
              FlowLayout layout4 = new FlowLayout(FlowLayout.LEFT, 10,10);
              paymentPanel.setLayout(layout4);
              paymentPanel.add(paymentLabel);
              paymentPanel.add(paymentField);
              pane.add(paymentPanel);
              //add components to textPanel
              FlowLayout layout5 = new FlowLayout(FlowLayout.LEFT, 10,10);
              textPanel.setLayout(layout5);
              textPanel.add(balLabel);
              textPanel.add(ytdPrincLabel);
              textPanel.add(ytdIntLabel);
              pane.add(textPanel);
              //add components to displayPanel
              FlowLayout layout6 = new FlowLayout(FlowLayout.CENTER,10,10);
              displayPanel.setLayout(layout6);
              displayPanel.add(scroll);
              pane.add(displayPanel);
              setContentPane(pane);
              setVisible(true);
         public void actionPerformed(ActionEvent event)
              String fs = (String)loanSelection.getSelectedItem();
              if (fs.equals("7 years @ 5.35%"))          {
                   displayArea.setText("yay");
              else
                   displayArea.setText("blah");
              JButton command = (JButton)event.getSource();
              if(command==calcButton)  //calculate button clicked - run payment event
                   Payment();
              if(command==clearButton) //clear button clicked - clear all fields
                   mortAmtField.setText(null);
                   paymentField.setText(null);
                   displayArea.setText(null);
                   loanSelected.setText(null);  //hidden text field still needs to be cleared
                   //loanChoices = null;
              if(command==exitButton)  //exit button clicked - exit program
                   System.exit(0);
         public void Payment()
              //perform the calculations
    //          int mortAmt = Integer.parseInt(mortAmtField.getText());
         //     double loanSelect = Double.parseDouble((String)loanSelected.getText());
              displayArea.append("Calcualations performed!");
         public static void main(String[] args)
              new MortCalcSR5();
    /*/calculations
         int mortAmt = Integer.parseInt(mortAmtField.getText());  //get text user entered in mortAmt field - parse it from a string to integer
         int loanTerm = Integer.parseInt(loanTermField.getText());  //get text user entered in loanTerm field - parse it from a string to integer
         double interestRate = Double.parseDouble(interestRateField.getText());  //get text user entered in interestRate field - parse it from a string to double
         int moTerm = (loanTerm*12);  //calculate monthly loan term
         double moInterest = ((interestRate/100)/12);  //calculate monthly interest rate
         double payment = mortAmt*(moInterest/(1-Math.pow(1/(1+moInterest), moTerm)));  //calculate monthly payment amount
         valid = true;  //number format is accepted
         paymentField.setText(Double.toString(payment));  //display output
    */

  • How do i create arrays more efficientl​y

    how do i create arrays more efficiently?... need to insert data into an array every loop iteration.  I am using the insert into array function and shift registers.  I have been told this is inefficient... and they are right because I can make the program stop and it gives me the error that labview does not have enough memory.  A coworker said to avoid shift registers and investigate property nodes... i am new at this and don't know what this is exactly.. is there a tutorial on efficent data handling.. or examples that would be usefull? 

    tbob wrote:
    Mark is absolutely correct.  Indexing will take a lot of memory and a lot of time when the array gets large.  Indexing is great for small arrays though. With indexing, the first loop iteration will create an array of size 1.  On the next loop, the array has to be copied, re-dimensionedcto size 2, old data copied to new array, and new data inserted at end.  You can see how this will become a monster with an array size of 10,000.  With pre-allocation, there is no re-dimensioning and no copying.  Array elements are simple replaced.  And yes you do have to know the upper limit to use pre-allocation.  Kudos to Mark for pointing out the facts.
    A bit of a clarification is needed. Folks from NI told me that LabVIEW tries to be smart when autoindexing. When they allocate the memory the initial chunk of memory it is larger than a single element. So you don't necessarily get a copy and allocation every iteration. They may have improved the optimization to preallocate the complete array if the size is already known (a constant wired to the loop count). However, they would have no way of doing this if the number of iterations is not known ahead of time.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Is it possible to combine multiple Pur Reqs for multiple materials to one vendor into one PO through MD07?

    We have material planners who use MD07 (traffic signal screen) Stock/Requirements List, Collective Access tab to review material requirements by MRP Controller.  Once the list is created, they select individual materials and review them in MD04.  In a lot of cases, Purchase Reqs (PRs) are reviewed and adopted into POs individually for each material.  Sometimes they will combine multiple PRs for one material into one PO.  This is a good practice.  However, from what I have found, it is not possible to combine multiple PRs for multiple materials into one PO.  If this was done it would dramatically reduce the number of POs that we are issuing to suppliers.  Problem statement:  We issue too many POs which causes additional influxes down the line (receiving dock/goods receipts processing, receiving issues, invoices, invoice issues, etc.).  Does anyone know of a way to address this problem without a major overhaul in approach or customization of the system?  Thank you in advance!   

    Hello Michael
    As far as I know, this is not possible directly from MD07, only from the MM transactions.
    The following thread suggests the following procedure to convert several PRs into one PO:
    Conversion of multiple PR into single P.O
    Drag and drop the first PR from the item overview to the shopping card on top of ME21N,
    then open the PO detail delivery schedule tab and drag  and drop all other PR to the shopping card shown  in the schedule tab
    You can use the same procedure, calling the order conversion from MD07 and then drag and drop another PRs into this PO.
    BR
    Caetano

  • Is it possible to have a book in more than one iBook collection?

    Is it possible to have a book in more than one iBook collection?

    No. A book can only be moved to one collection at a time.

Maybe you are looking for

  • Chronic "There was a problem connecting to the server "Chronos"." alert.

    There was a probem conecting to the server "Chronos". The server may not exist or it is unavaliable at this time. Check the server name or IP address, check your network connection, and then try again.       I have been getting this alert for about t

  • What is the maximum temperature for a macbook generic processor to operate?

    Right now the temperature for my cpu is 185 degrees Fahrenheit. Is that bad? Whats the highest temperature a Macbook can properly operate?

  • NHL Gamecenter Live problems

    Curious if anyone began to have problems with NHL Gamecenter Live last night.  I was able to watch games through aTV2 until about 9:30 PM EST last night, and then, all of a sudden, when I go into the games option to attempt to watch live content, I g

  • Hi i am getting error in xml form builder

    hi i created edit,renderlistitem,show  i haveadded buttons from extras-buttons i am getting error as Error:Edit form doenot contain save button or link what could be the reason how to solve it pls reply

  • Trying to get personal info (online predator)

    total.dear73 tryed to get my real name and where i lived. I blocked him/her i have a screen shot to prove this but im not linking it on a this public board. I'm not sure if Skype can do anything about it or check them out. Just want to make Skype a s