Insert 2D Array in 2D Array

okay... I have the following case:
I have a 2 inputs which are both arrays of numeric datatypes. Both arrays can have a different number of rows, only the amount of columns is the same.
For example:
array1: [[1,2]]
array2: [[3,4],[5,6]]
output array: [[1,2,3,4],[,,5,6]]
How do i achieve this? I have now a rather complex solution and think it must be possible that it can be done easier.

Two simple choices:  Build Array or Build Matrix.  For appending rows you can simply use Build Array with concatenate inputs selected.  For 2D scalars you can use Build Matrix and then have the option to append rows or columns.  Ignore the red coercion dot,  Array to Matrix is just a simple VI whose only purpose is to hide the dot so I tend to skip it.
I am guessing that you want the Append Cols output, if the default values of zero cause problems, well, then you are probably in for a bit of a complex solution.

Similar Messages

  • Inserting a character in an array

    i already have this piece of code:
    int length1=name1.length();
              int length2=name2.length();
              for(int g=0; g<length1; g++){
                   for(int k=0; k<length2; k++){
                   if(name2.charAt(k)==name1.charAt(g)){
                        if(name2.charAt(k)!=' '){ //excludes spaces to be inserted in the array
                             /*inserting of the character in the array is supposed to be here..but i dont know how it is done. im trying not to use classes.*/
    im trying to insert characters in an array that is found in both name1 and name2. there should be no same characters found in the array.

    a charachter array sounds allot like a String which has very useful methods like: indexOf, contains and replace, replaceAll. Have a look:
    [http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html]

  • Hihow to insert 2 elements into 2D array?

    Hi I had a hard time figuring out how to insert 2 elements into 2D arrays. 
    I tried using replace and insert array functions but it does not work right way.
    I am using LV7.1. See the pic below.
    How do I insert elements in that way?
    Pls advise
    Clement

    Well, "replace array subset" is not the right tool, because it keeps the size of the array constant. Insert into array only works for entire rows or columns.
    You need a hybrid approach, because you want to insert elements at the beginning of column 1 while padding the remaining columns to the new lenght of column 1. This won't be efficient but there are plenty of ways to do that (here is one example with DBL arrays, should work equally well for string arrays as in your case).
    How much flexibility do you need? Is it always at the beginning of the first column? Are the arrays huge (=is performance an issue)? Is this a rare operations or do you constantly need to do this (e.g. inside a loop).
    In any case this seems like a rather arbitrary and somewhat silly operation. What is the practical purpose?
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    WeirdMerge.vi ‏21 KB

  • How do I insert an object in an array?

    How can I insert an object in an array of variable size?
    I input two numbers from keyboard
    1
    2that form the following object (Pair)
    (1,2)
    how can I add such objects to an array
    private Pair s[];
    e.g.
    public PairList(int x){
    top = -1;
    s = new Pair[x];
    }//constructor
    public void getPairs()throws FullException{
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    try{
    a=input.readLine();b=input.readLine();
    }//try
    catch(IOException e){System.out.println("Can't read input");}//catch
    int x=0;
    int y=0;
    try{
    x=Integer.parseInt(a);}//try
    catch(NumberFormatException e){}
    try{
    y=Integer.parseInt(b);}//try
    catch(NumberFormatException e){}
    Pair k=new Pair(x,y);
    System.out.println(k);
    s[++top]=k; --here is my problem
    }//getPairs

    I tried making as few changes to your code as possible, but your idea should basically work. Potential problems:
    1. Doesn't allow for more input than 1 pair.
    2. By storing pair in an array, you must know the exact size of the array you will need beforehand. You might be better off storing the Pair(s) in a Vector and then converting that to an array.
    3.Your exception handlers need some work. Basically, your exception handlers put out a message or do nothing and then you continue processing. Not good.
    4. No cleanup of file resources after you have completed
    import java.io.*;
    public class PairList{
         private Pair s[];
         private int top;
         public PairList(int x){
              top = -1;
              s = new Pair[x];
         }//constructor
         public void getPairs()throws Exception{
              BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
              String a = null, b = null;
              try{
                   a=input.readLine();
                   b=input.readLine();
              }//try
              catch(IOException e){
                   System.out.println("Can't read input");
              }//catch
              int x=0;
              int y=0;
              try{
                   x=Integer.parseInt(a);
              }//try
              catch(NumberFormatException e){
              try{
                   y=Integer.parseInt(b);}//try
              catch(NumberFormatException e){
              Pair k=new Pair(x,y);
              System.out.println(k.toString());
              s[++top]=k; //here is my problem
         }//getPairs
    class Pair {
         private int xx;
         private int yy;
         public Pair(int x, int y) {
              xx = x;
              yy = y;
         public String toString() {
              return("X = " + xx + "  Y = " + yy);
    }

  • Last One I Promise! Inserting A Value In An Array And Shifting TheRest Over

    Last question I have, I need to know the theory behind inserting a value into an array and shifting the rest over.. I have somewhat of an idea and that is this:
    Obviously I need to use a for loop, and a temp value to hold each value until it shifts then move on to the next value? Oh and increase the size of the array by one? I'm having trouble making sense of it..
    lets say we have the same array as from before
              int[] aRay = new int[5];
              aRay[0] = 1;
              aRay[1] = 9;
              aRay[2] = 3;
              aRay[3] = 4;
    aRay[4] = 11;
    and we want to add... lets say the element 5 into the index spot of 2 is and shift 2 to 3 and 3 to 4 and 4 to 5.
    for ( int i = 0; i < aRay.length; i++) // this will move along each element of the array (so I know I need this for sure)
    Am I on the right track? thanks all
    Edited by: Jojobaba on May 13, 2008 11:50 PM
    Edited by: Jojobaba on May 13, 2008 11:54 PM

    Jojobaba wrote:
    I can do all that, the only trouble I'm having right now is what's the correct way to increase the size of the array by one more? if I try to declare 4 as 5 it gives me a runtime error because 5 is out of bounds, and rightly so, because it doesn't exist
    Once I get that, the rest will be cake
    int[] aRay = new int[5];
    ^
    l
    l
    Do I just make this a 6? or is that not the right way.. :/You can't change array sizes dynamically. You will have to make a new array of the appropriate size and copy into it. You could use copyOf: http://java.sun.com/javase/6/docs/api/java/util/Arrays.html#copyOf(int[],%20int)
    I hope this is purely an academic exercise, because there's no reason to do this.

  • Inserting a record into an array

    I have an applet that pops up different frames when you click on a menu item. On my add a record frame I have a number of textfields and an add button. When the button is clicked it is supposed to insert the record into my array of objects that only can have 3 records. When the button is clicked however I get a null pointer exception. I want to add the record in order based on the employee number, so first I want to check to see if the first spot of the array is null and add the record in the first spot if it is. If it isn't I want to check the employee numbers and insert the the record in the correct place and make sure the array isn't full. Can someone help me out 1. Why the nullpointer exception. 2. I am not sure if my logic is correct. Below is the Code. Thanks!!
    public void insertRecord()
    if (MyEmpArray[0] == null )
    addRec(0);
    else
    for(int index =0; index <3; index++)
    if(intEmpNumber < MyEmpArray[index].intEmpNumber && MyEmpArray[3] != null )
    addRec(index);
    else
    lblErrorMessage.setText("Array is full");
    public void addRec(int index)
    MyEmpArray[index].setValues(intEmpNumber, strFirstName, strLastName, strHomePhone,
    strStreet, strCity, strState, strZip, strCountry, strWorkStreet,
    strWorkCity, strWorkState, strWorkZip, strWorkCountry, strWorkPhoneNum,
    fltNumHours, fltHourlyWage, intI, intJ, intK);
    lblErrorMessage.setText("");
    txaReport.setText("");
    ClearFields();
    }

    for(int index =0; index <3; index++)
    An array with an index from 0 to 3, contains 4 records: you should replace it with
    for(int index =0; index <2; index++)
    The check-logic is good enough, but there are two minor "bugs":
    1) even If the array is full, the for cycle will uselessly check all the records
    2) if a the employee number of intEmpNumber is > thanMyEmpArray[index].intEmpNumber the program will show up "Array is full" even if the array isn't full.
    So, I suggest to add more code to make distinction between the two cases:
    for(int index =0; index <3; index++)
    if(MyEmpArray[3] != null ) // check if there is space to add a record
    if (intEmpNumber < MyEmpArray[index].intEmpNumber) //check if the position is right
    addRec(index);
    else
    lblErrorMessage.setText("Array is full");
    break; // exit the for cicle as the array is full
    I don't know what you are programming, but I ask you: "If the new intEmpNumber is < than the intEmpNumber of an already-full-array shouldn't be the new record inserted, discarding the last one?"
    I don't know if addRec works, I'm don't know applets, buttons..:)
    Sorry for my bad english...I hope this post will help you anyway :)

  • Difference between INSERT and EXTEND in OBPM Arrays

    Hi all,
    I wanted to know the diference between the EXTEND keyword and INSERT keyword while using OBPM arrays.
    For e.g. if testArray is an Array then:-
    What does testArray.insert mean?
    And
    What does testArray.extend mean?

    Extend inserts at the end of the array. Insert allows you to specify an index into the array where you want to insert to.

  • Array pointer in array

    Can anybody tell me how to create pointers in an array pointing to other arrays?

    RichL wrote:
    Hi tbob,
    thanks for your suggestion! I did build it up with three arrays and a numeric control to select one of the arrays, which works fine. However, there are the following effects which I don't understand yet.
    1. The RefArray can only be defined as Variant, showing a violet colour instead of a green/blue as in your example; I could not find a refnumber without giving me an error.
    2. By changing the array selector, following array elements are being written into: 1,1 of array0; 0,0 of array1 and 1,0 of array2. I don't see why it is different for each array. Is there a possibility to select the array element being written into?
    My VI is attached, LV7.1
    Kind regards
    Richard
    Strange, when I created my vi, the RefArray was blue-green, not a Variant.  On the front panel I placed a blank array.  Then I placed a Control Refnum into the array.  Now the array is defined as a Control Refnum Array, not a Variant.
    Attached is a vi similar to the picture I had previously attached.  In your case, you would need a slightly different method because of your unknown quantities of channels for each source.  The use would select a source, and then you would have to retrieve an array of channels for that source.  The user then selects a channel, and you would have to retrieve the data for that channel.
    Post what you have so far so that we can look at it.
    - tbob
    Inventor of the WORM Global
    Attachments:
    RefArray.vi ‏50 KB

  • Can't duplicate movieclips as an array within an array

    Hello.
    I have an animation that loads an xml into it and traces back
    an array within an array. I have tried to apply this to duplicated
    movieclips thereby creating a structured set of links. What I am
    trying to do is this:
    Chicken Nuggets
    __Compression
    __Texture
    __Disgust
    Mega Warhead
    __Taste
    __Hardness
    __Pain
    This traces fine but I can't seem to get the duplicated
    movieclips to assemble in this fashion.
    The code for the XML is as follows:
    var controlArray:Array;
    var variable:Array;
    var testTopic = new Array ();
    var test = new Array ();
    var controlsXML:XML = new XML();
    controlsXML.ignoreWhite = true;
    controlsXML.onLoad = function(success:Boolean){
    if (success){
    var mainnode:XMLNode = controlsXML.firstChild;
    var controlNodes:Array =
    controlsXML.firstChild.firstChild.firstChild.firstChild.childNodes;
    var list:Array = new Array();
    for (var i:Number = 0; i < controlNodes.length; i++) {
    var personnode:XMLNode = controlNodes
    .attributes.Name;
    trace(personnode);
    testTopic.push (new struct (personnode));
    var specificNode:Array = controlNodes.childNodes;
    for (var j:Number = 0; j < specificNode.length; j++){
    var itemnode:XMLNode = specificNode[j].attributes.Variable;
    trace(itemnode);
    test.push (new struct2 (itemnode));
    printer ();
    printer2 ();
    } else {
    trace('error reading XML');
    controlsXML.load ("controls3.xml");
    The code for the movieclip duplication is as follows:
    x = 50;
    function printer ()
    for (m = 0; m < testTopic.length; m++)
    duplicateMovieClip ( slotTopic, "slotTopic" + m, m );
    slotTopic = eval ( "slotTopic" + m );
    slotTopic._y += x;
    slotTopic.slotTopicContent.text = testTopic[m].personnode;
    function printer2 ()
    for (k = 0; k < test.length; k++)
    duplicateMovieClip ( slot, "slot" + k, k );
    slot = eval ( "slot" + k );
    slot._y += x;
    slot.slotContent.text = test[k].itemnode;
    function struct (personnode)
    this.personnode = personnode;
    function struct2 (itemnode)
    this.itemnode = itemnode;
    On the stage are two movieclips, titled "slotTopic" and
    "slot". Within those are dynamic text boxes titled respectively
    "slotTopicContent" and "slotContent". When I preview this file it
    only displays the text within the "slot" movieclip and it lists all
    six of the subtopics with no break. So, there are two dilemmas:
    1) The movieclips won't duplicate into the structured set of
    links that I want.
    2) "slotTopic" is not displaying text at all.
    If anyone has any advice, I'd really appreciate it.
    Thx!

    ok, I'm sorry but there are quite a few things wrong here.
    first though, when posting code please use the 'attach code'
    button.
    1) i can't imagine that you have a XML structure as deep as
    your calling to or the need for it with the limited amount of
    infomation your pulling, in addition your storing the info in
    attributes, so I can't see how this would work, it may 'trace' out
    the right text (somehow) but it's not getting into the arrays
    properly.
    2) you do not assign an attribute value to a XMLNode, and
    then try to push it into an array.
    3) you do not call a method (struct or struct2) using the
    'new' operator. this is how you envoke a new 'class' instance.
    4) do not use 'x' as a variable name as it is a reserved var
    in flash, assigned to an Object instance.
    5) the duplicateMovieClip() method needs to be called upon
    the existing clip as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m);
    additionally you can pass the _y placement within the
    initObject.
    6) you do not need to use eval, it isn't doing anything here,
    you will gain the correct path by calling duplicateMovieClip
    correctly.
    7) the reason why slotTopic is not being displayed at all is
    because of the second loop, you are duplicating the clips
    (incorrectly) into the same depths thereby replacing all of the
    contents of the slotTopic depths previously constructed.
    the solution to this problem is to construct both items with
    the same loop but increament one of the depth assignments by a
    specific number, in other words at depths much higher or at least
    different, than that of the first element, as in:
    slotTopic.duplicateMovieClip('slotTopic'+m, m, {_y:50});
    slot.duplicateMovieClip('slot'+(m+100), m+100, {_y:50});
    again I'm sorry man, but it will take some work to sort this
    out.

  • Mapping vertical arrays versus horizontal arrays in HP exstream

    Anyone with details on mapping vertical arrays versus horizontal arrays in HP Streak software please?

    johnsold wrote:
    Is this a bug (inconsistent behavior)? A feature? An unintended consequence of something else?
    I agree, this looks inconsistent.
    Ranjeet_Singh wrote:
    Make the index of both the array 0 then run your program. 
    Now horizontal array shows 4th element & vertical array shows 10th element. 
    What are you trying to say here? You are just repeating the instruction #1 on the front panel of the posted VI, then repeating what the image above already shows.
    LabVIEW Champion . Do more with less code and in less time .

  • Assigning javascript array with jsp array

    hi,
    I have a jsp page where I have a array in jsp. I want to assign the values to an javascipt array. how can I do that?
    the reason why I want to do this is for a perticular problem I am facing in javascript. that is....
    I have a text box in my jsp page, I want the value entered in that box to be checked (whether it exists ) against a hidden string which has some value. I want that hidden string not to be shown to the user even on seeing the html source. that is why I want these values to be stored and checked against a array object of javascript.
    any suggestion is appreciated
    Thanks
    Ashutosh

    Hai asutoshdash
    if you dont mind of viewing code u can use this else dont use, its not matters weatehr user will see you code or not if the user is professiona then its a big issue normal users not think of is for this dont send valuable infos like password etc to client u may send usernames
    ok to create a java array to javascript array do this (i took example of db to array ) write this inside <script> <%codes here%> </script>
    var aUsername =new array();
    <%
    int i=0;
    while (rs.next())
    %>
    aUsername[<%= ++i%>] = "<%= rs.getString("User_Name")%>";
    <%
    %>thats it use this array where ever you want in your client side(javascript ) usage
    hope this will help you
    archi

  • Array inside another array

    hi guys
    is it posible to place one array inside another array?
    something like
    public double[] dblarray(int n)
    double [] dbl2 = new double(n)
    return dbl2;
    public double[] dbl2array(int m,int n)
    int n=10
    double [] dbl2 = new dobule[m];
    for(int i = o;i < m ; i++)
    dbl1=dblarray(n)
    if tryed it an it told me its wrong. does any one know how to do it or if it is posible since i come from ansi c i know this is posible in c but is it in java???
    pleas help:)
    thanks
    jeliel

    No, it's not possible in a strict sense. Java is more type safe than C - in C there is no real array type...
    What you can have is an array of references (=pointers) to arrays of doubles, or double[][], and what your code does is more commonly written asdouble[][] dbl2 = new dobule[m][10];

  • Cast Object Array to String Array.

    When I try to cast an object array to string array an exception is thrown. How do I go about doing it?
    Vector temp = new Vector();
    Object[] array = temp.toArray();
    String[] nonterms;                              
    nonterms = (String[])array;
    Thanks,
    Ally

    Try this
    import java.util.Vector;
    public class Test
         public static void main(String args[]) throws Exception
              Vector v = new Vector();
              v.add("a");
              v.add("b");
              v.add("c");
              Object[] terms = v.toArray();
              for(int i = 0; i < terms.length; i++)
                   System.out.println((String)terms);
    Raghu

  • Converting an array to an array collection

    When converting an array to an array collection, is it good
    practice to remove the original array? If so, how does one do
    that?

    My 2 cents - I think it may be unnecessary. The garbage
    collector should notice a lack of references to the original array
    and delete it for you.

  • Array of String Arrays

    How do I make an array of String Arrays, not knowing how big the array will be
    or how big any of the arrays it contains will be at the time I create it?

    The size of an array is not dynamic, i.e. if you use an array, you must know its size at the time you create it.
    Use one of the collection classes (like java.util.Vector or one of the implementation classes of java.util.List).
    regards
    Jesper

  • How to convert an int array to string array?

    Hi,
    Can anyone please help me with this question?
    int number={4,6,45,3,2,77};
    I like to convert this into a list and sort
    List mylist = Arrays.asList(number);
    Collections.sort(mylist);
    But first I need to convert the int array to String array.
    Please advise. Thanks.

    If you want to convert your int array to a String array, you have no choice but doing a conversion element by element in a for loop.
    However, if the sort method doesn't behave as desired, you can use the one with 2 parameters, the second parameter being a comparator class.
    Check the javadoc for more information : http://java.sun.com/j2se/1.3/docs/api/java/util/Collections.html
    /Stephane

Maybe you are looking for

  • Photoshop Elements 6 Slideshow Issues

    Photoshop Elements 6 Core Version: 6.0 (20070910.r.377499) Issues: Ordering Slide Shows They will not order in File Name order -- Must I do it manually? -- which is silly for a computer Slide Show Photo Background File name picked up as title/descrip

  • Message Mapping - External Definitions

    My Scenario 1) File1(Request with Employee Number) - Sent to XI (Async) 2) XI will send the Request over HTTP and will Receive the Response(Employee Details) (Synchronous) 3) The HTTP Response will be sent to File2(Employee Details) (Async) The Reque

  • Added new memory, now computer won't boot at all

    Hello I added a new pair of 2*8GB Coursair memory along with my old memory which was 2*2GB, for a total of 20GB Ram. It was working fine for a day (except one random restart), but got steadily worse. Yesterday iMac was shutting and restarting more fr

  • Catalog status update

    Hi , can anyone let me know how to update the catalog status in the table /CCM/D_PUB_ST from 'R' to 'E' or from any status to error status. thanks in advance

  • A popup message when i  double click a packagebody

    hi, i get a problem when i use the sqldeveloper 3.0, usually when i double click a packagebody and there will be a popup message: the connection is busy.try again? is it the expected alert? Thanks.