Splitting an array

Hi guys,
I am trying to modify a program at work with LabVIEW, but I am only a beginner at it so I am having a few problems. Basically, it is a data acquisition program that gets it data from accelerometors. The data is read using the AI read function, output to an array and then plotted onto a waveform chart. I am trying to modify the program so that the data gets plotted on three seperate charts instead of one, becuase it was very hard to read before, with 25 channels on it. I thought I could do this by using an "array subset" function to split the 25 channels into 5,15,5 channels onto three seperate charts. For some reason this isn't really working too well, and I'm not really sure how to try and debug it. I have a background in C and MatLab and I know how to use those debuggers, but I am definitely struggling with LabVIEW. Could anyone tell me why my program isn't working or at least help me debug it somehow.
I have attached the program. The modifications that I have made are in the top right corner - the addition of the three "array subset" functions.
Attachments:
SKM2.vi ‏105 KB

I can't test the code because I can't take data with this PC, but I'm pretty sure the problem is with your array indices -- the numbers are right, just hooked up to the wrong dimension.
Try this out.
-Matt Bradley
************ kudos always appreciated, but only when deserved **************************
Attachments:
SKM2[1].vi ‏53 KB

Similar Messages

  • Memory/Speed of Split 1D array vs Delete from array

    Just wondering how Split 1D array works - does it create two new arrays in a new section of memory or does it just split the existing array in two, reusing the memory in place. (assuming that the original array is not needed elsewhere). If the latter is the case then presumably it is more efficient to use split array than delete from array if I want to remove element(s) from the beginning or end of the array. Is there a speed advantage as well?
    If I use split array but don't then use one of the output arrays is that memory deallocated or does the array remain in memory?
    Thanks
    Dave

    Ok please ignore the results I posted earlier, they are rubbish - not least because I got the column headings mixed up but also because my code was full of bugs
    So, here is a revised table, and the code - which hopefully only contains a few bugs... I'm not clued into benchmarking yet so please feel free to rip the code apart.
    I still get different results depending on where in the array I split it, most noticeably with subset and reshape. There is no effect with split. I'm guessing this is to do with the memory allocation. (I have not preallocated memory in my code, but I did wire the output arrays to Index Array)
    Message Edited by DavidU on 08-12-2008 04:49 PM
    Attachments:
    Benchmarks 2.png ‏13 KB
    split array test.vi ‏25 KB

  • Splitting an Array to 4 Quadrants

    Hello,
    I'd like to split a 2D array into 4 Quadrants. The Array's size is 640 by 480 (made from a png graphic) and i would like to search for specific colors in each Quadrant.
    So i'd need 4 output Arrays with the coordinates 0-320/0-240, 0-320/241-480, 321-640/0-240 and 321-640/241-480.
    Has anybody made this before? I have only found functions to split the Array linewise, on the whole width only.
    Thanks very much for any hints.
    andy
    Attachments:
    arrsplit.jpg ‏21 KB

    randerson wrote:
    I'd like to split a 2D array into 4 Quadrants. The Array's size is 640 by 480 (made from a png graphic) and i would like to search for specific colors in each Quadrant.
    So i'd need 4 output Arrays with the coordinates 0-320/0-240, 0-320/241-480, 321-640/0-240 and 321-640/241-480.
    Also try to get the math straighened out.
    The first element is element [0;0]!. If the array size is 640x480, the highest indices are 639 and 479, respectively. To split it in four quadrants of equal size, you want indices:
    0-319/0-239
    0-319/240-479
    320-639/0-239
    320-639/240-479
    Right?
    About the search: What do you actually want? (e.g. how many times a color occurs in each quadrant? a list of all indices?)
    LabVIEW Champion . Do more with less code and in less time .

  • How can I inverse the Split 1D Array by recombining the splitting array?

    How can I inverse the Split 1D Array by recombining the splitting array? i.e I have two boolean arrays A and B, and I want them in one boolean array: A array elements followed by B elements (NOT Interleaving)
    Thank you
    Solved!
    Go to Solution.

    Thank you Marcus_Körner , GerdW and thoult for your assistance.
    Sorry I am using Labview 2013, so I saved it in ver 2010 format, and I uploaded a photo for the circuit.
    Attachments:
    Packets.vi ‏8 KB
    Untitled.png ‏5 KB

  • How to split an array (*not String*) into smaller arrays?

    Hello,
    let's say you have an array of bytes whith length (for example) 5000B. Now you want to split this array into smaller ones, for example 1500B. Then you will have 3 arrays of 1500B and another one of 500B. What I try to do then is the following:
    pointer = 0;
    size = source.length; // For example, size = 5000
    maxsize = 1500;
    while ((size - pointer) > maxsize) {
       byte[] dest = new byte[maxsize];
       System.arraycopy(src, pointer, dest, pointer, maxsize);  // <--- Errors here!
       pointer += maxsize;
       // Do some stuff here with the dest array
    }There's no errors at compile time. But at runtime, the first iteration everything works OK (the 1500 first bytes are copied to the dest array). However, in the second iteration, the java interpreter claims:
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
            at java.lang.System.arraycopy(Native Method)And I don't know what I'm doing bad. I guess there's a stupid question I can't see by myself... Help wanted, please!

    > System.arraycopy(src, pointer, dest, pointer, maxsize);should be
    System.arraycopy(src, pointer, dest, 0, maxsize);Since you're copying to the first position in the destination array.

  • Split 1d array in 2d

    Hi,
    I want to split a 1d array of paths in an 2d array. Enclosed I have a copy of my 1d path-array. The aim should be that all filenames without extensions are in in one row. E.g.: 1st row:  00124241--.bst, 00124241--.dat,00124241--.par 2nd row: 00124244--.dat, 00124244--.par - and so on. My static solution for that can't handle a missing file type because of the modulo function of the file types.
    Has anybody an idea?
    Kind Regards,
    Joachim
    Solved!
    Go to Solution.
    Attachments:
    1d-array.JPG ‏12 KB
    static.JPG ‏53 KB

    Try something like this. Modify as needed.
    Message Edited by altenbach on 01-07-2009 01:21 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    TEMP_TEST_1D-DATA_MOD.vi ‏15 KB
    SortFilesTo2D.PNG ‏27 KB

  • Split 2D array to 1D arrays by row

    Hi
    I am trying to do 2 things with arrays and their dimensions. They both seem quite basic, but I can't figure out how to do them...
    1. Split a 2D array of size 2 x N into two 1D arrays of length N.
    2. Reshape a 2D array of size m x n into a 1D array of length mn, then do the inverse procedure and get it back to a 2D m x n array. (After doing some manipulation, interpolation, etc.)
    Thanks!

    Justin_Reina wrote:
    Back to the original question -
    1. Split a 2D array of 2xN into (2) 1D arrays of len N
         This code achieves this. It uses the cluster datatype to conceptually & visually segment
          the problem-statement's solution - try to make a cleaner visual solution
    A cleaner visual solution would be to just leave it as a 2D array! The existing display of rows and columns is very clear and easy to view and understand! Why all that song and dance of using complicated hierachical structures? Since when did the word "split" mean "wrap it into a complicated structure for easier viewing"?
    Justin_Reina wrote:
     I don't care about ragged 2D arrays, AKA 'sloppy programming' ... See the answer above
        for my clarifications.
    Ragged arrays have nothing to do with sloppy programming. They are a valid data structure useful for certain scenarios.
    Justin_Reina wrote:
    So ummm, thanks for your direct & public sarcasm but I would suggest that occur on the side in email in the future...
    Well, a public post deserves a public answer. I am probably not the only one confused by your post dangling from the end of an ancient solved thread so a public clarification is beneficial to all. Besides, your e-mail address is probably not public and even if I had it, e-mailing somebody out of the blue would need a very, very good reason. I rarely do that.
    I just asked for clarification and pointed out what parts of your posts confused me in the context of the original thread. No sarcasm anywhere.

  • Trying to use .split with an array element

    I have tried multiple ways to split an array element into its components that are separated with a space with this code:
    public static void compareHand(String[] hand){
            for (int i = 0; i < hand.length; i++){
                System.out.println(i);
                System.out.println(hand);
    String[] tokens = hand[i].split("\\s");
    System.out.println(tokens.length);
    for (int j = 0; j < tokens.length; j++){
    System.out.println(tokens);
    I keep getting strange output like the following:
    King of Spades
    3
    [Ljava.lang.String;@10b62c9
    [Ljava.lang.String;@10b62c9
    [Ljava.lang.String;@10b62c9
    where I am expecting:
    King of Spades
    3
    King
    of
    Spades
    Any ideas where I am going wrong?

    public static void compareHand(String[] hand){
             for (int i = 0; i < hand.length; i++){
                  System.out.println(i);
                  System.out.println(hand);
    String[] tokens = hand[i].split("\\s");
    System.out.println(tokens.length);
    for (int j = 0; j < tokens.length; j++){
    System.out.println(tokens); // your error is on this line. Hint ... System.out.println(tokens[...]);

  • Split array from FIFO

    Hello
    I'm running a FIFO from my CRIO 9075 to a RT host on the computer. On the target I have 4 inputs connected to a build array and then FIFO.
    How can I split the array up into 4 separate signals on my host? 
    Solved!
    Go to Solution.

    The Index Array can be extended to separate all 4 of your elements.  That would likely be the easiest way for you to do this.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Crystal report - how to split a field into more fields

    Hello,
    I`m new to Crystal reports and I`ve got a trouble. I have field which contains an address - street, city, zip code. The example is:
    STEHLIKOVA 977 165 00 PRAHA 620 - SUCHDOL 165 00.
    What I need to achieve is to split this string into three separated fields. I`ve trouhg a couple of forums but haven`t been able to find a proper answer. The problem is that the addresses differ so I can`t use an absolute defining of a start position. Looking at the DB (HEXA code) the parts in the string are divided by two dots:
    STEHLIKOVA 977..165 00 PRAHA 620 - SUCHDOL..165 00
    I`ve been able to work out this solution:
    stringVar array x := split({cparty.STREET_ADD},"..");
    Local numberVar i;
    Local stringVar outputString := "";
    For i:=1 to Count(x) do
    outputString := outputString + x[i] + Chr(10)
    outputString;
    It splits the string into three rows:
    STEHLIKOVA 977
    165 00 PRAHA 620 - SUCHDOL
    165 00
    And I don`t know how to find the end of each row so to be able to separate the strings and report them as three different fields.
    Would be anyone so kind and help me out with this?
    Thank you.
    Petr

    Hi
    Actually using a for loop is not necessary here. All you need to do is to add several formula fields: one for street, one for city and one for zipcode. In @street field you add formula:
    stringVar array x := split({cparty.STREET_ADD},Chr(13));
    x[1];
    Then you drag such formula field to details section of your report and watch preview to check if everything looks alright. Repeat for every formula field that you'd like see in your report.
    In @city you add almost identical formula but you change index, i. e. instead of x[1] you need to use x[2]. Then for @zip x[3].
    You may need to check if your address has all three parts - for example if you want to use formula in the second part of your address field you may need check first if there are at least two parts after split:
    stringVar array := split({cparty.STREET_ADD},Chr(13));
    numbervar c; 
    c := count(x); 
    if 2 <= c then 
    x[c]; 
    Var 'c' is used to store the number of elements in array after split. Then I'd like to check if the part (second) actually exists. So I try to check if number of part that I want to refer to is not bigger than the number of elements in array after split (here stored in var 'c').
    Actually the code presented above is not enough since you have no guarantee that you'll always get address structured in the very same way. For example in demo PL database I have zip code and city in the same row after split with Chr(13) as delimiter.
    You'll need to experiment or ask someone to prepare correctly structured data coming from B1 to your report.
    Kind regards,
    Radek

  • How to set the value of an array element (not the complete array) by using a reference?

    My situation is that I have an array of clusters on the front panel. Each element is used for a particular test setup, so if the array size is three, it means we have three identical test setups that can be used. The cluster contains two string controls and a button: 'device ID' string, 'start' button and 'status' string.
    In order to keep the diagrams simple, I would like to use a reference to the array as input into a subvi. This subvi will then modify a particular element in the array (i.e. set the 'status' string).
    The first problem I encounter is that I can not select an array element to write to by using the reference. I have tried setting the 'Selection s
    tart[]' and 'Selection size[]' properties and then querying the 'Array element' to get the proper element.
    If I do this, the VI always seems to write to the element which the user has selected (i.e. the element that contains the cursor) instead of the one I am trying to select. I also have not found any other possible use for the 'Selection' properties, so I wonder if I am doing something wrong.
    Of course I can use the 'value' property to get all elements, and then use the replace array element with an index value, but this defeats the purpose of leaving all other elements untouched.
    I had hoped to use this method specifically to avoid overwriting other array elements (such as happens with the replace array element) because the user might be modifying the second array element while I want to modify the first.
    My current solution is to split the array into two arrays: one control and one indicator (I guess that's really how it should be done ;-) but I'd still like to know ho
    w to change a single element in an array without affecting the others by using a reference in case I can use it elsewhere.

    > My situation is that I have an array of clusters on the front panel.
    > Each element is used for a particular test setup, so if the array size
    > is three, it means we have three identical test setups that can be
    > used. The cluster contains two string controls and a button: 'device
    > ID' string, 'start' button and 'status' string.
    >
    > In order to keep the diagrams simple, I would like to use a reference
    > to the array as input into a subvi. This subvi will then modify a
    > particular element in the array (i.e. set the 'status' string).
    >
    It isn't possible to get a reference to a particular element within an
    array. There is only one reference to the one control that represents
    all elements in the array.
    While it may seem better to use references to update
    an element within
    an array, it shouldn't really be necessary, and it can also lead to
    race conditions. If you write to an element that has the
    possibility of the user changing, whether you write with a local, a
    reference, or any other means, there is a race condition between the
    diagram and the user. LV will help with this to a certain extent,
    especially for controls that take awhile to edit like ones that use
    the keyboard. In these cases, if the user has already started entering
    text, it will not be overwritten by the new value unless the key focus
    is taken away from the control first. It is similar when moving a slider
    or other value changes using the mouse. LV will write to the other values,
    but will not rip the slider out of the user's hand.
    To completely avoid race conditions, you can split the array into user
    fields and indicators that are located underneath them. Or, if some
    controls act as both, you can do like Excel. You don't directly type
    into the cell. You choose w
    hich cell to edit, but you modify another
    location. When the edit is completed, it is incorporated into the
    display so that it is never lost.
    Greg McKaskle

  • How to insert values into an array of class

    Hello everyone,
    I need help in inserting values into an array of class, which i have read from a file.
    Length of the array is 5. I should insert values one by one into that array.
    If the array is full (if count = 5), then I should split the array into 2 arrays
    and adjust the values to left and right with median.
    I'm getting an ArrayBoundException .. can anybody help me out ?
    Thanks in advance
    Here is my code..........
    import java.util.*;
    import java.io.*;
    public class Tree
         static String second;
         static String first;
         static int count = 5;
         public void insert(int f1,int s1, int c)
              if(c!=0)
                   Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                   for(int i = 0; i<=4;i++)
                        rec.x = f1;
                        rec[i].y = s1;
              else
                   System.out.println("yes");
         public static void main(String[] args)
              Tree t = new Tree();
              try
                   FileReader fr = new FileReader("output.txt");           // open file
                   BufferedReader br = new BufferedReader(fr);
                   String s;
                   while((s = br.readLine()) != null)
                        StringTokenizer st = new StringTokenizer(s);
                        while(st.hasMoreTokens())
                             first = st.nextToken();
                             second = st.nextToken();
                        //     System.out.println("First-->"+first+" "+"Second-->"+second);
                        int fir = Integer.parseInt(first);
                        int sec = Integer.parseInt(second);
                        t.insert(fir, sec, count);                    
                   fr.close(); // close file           
              catch (IOException e)
    System.out.println("Can't read file");
    class Record
         public int x,y;

    Hi qwedwe.
    Record[] rec = new Record[4];
                   for (int i = 0; i < 5; i++)
                          rec[i] = new Record(); 
                     }Here is your error: you have an array of 4 Records, but you create and (try to) insert 5 Record-instances.... try:
    Record[] rec = new Record[c];
                   for (int i = 0; i < c; i++)
                          rec[i] = new Record(); 
                     }Regards,
    Norman

  • Converting object wrapper type array into equivalent primary type array

    Hi All!
    My question is how to convert object wrapper type array into equivalent prime type array, e.g. Integer[] -> int[] or Float[] -> float[] etc.
    Is sound like a trivial task however the problem is that I do not know the type I work with. To understand what I mean, please read the following code -
    //Method signature
    Object createArray( Class clazz, String value ) throws Exception;
    //and usage should be as follows:
    Object arr = createArray( Integer.class, "2%%3%%4" );
    //"arr" will be passed as a parameter of a method again via reflection
    public void compute( Object... args ) {
        a = (int[])args[0];
    //or
    Object arr = createArray( Double.class, "2%%3%%4" );
    public void compute( Object... args ) {
        b = (double[])args[0];
    //and the method implementation -
    Object createArray( Class clazz, String value ) throws Exception {
         String[] split = value.split( "%%" );
         //create array, e.g. Integer[] or Double[] etc.
         Object[] o = (Object[])Array.newInstance( clazz, split.length );
         //fill the array with parsed values, on parse error exception will be thrown
         for (int i = 0; i < split.length; i++) {
              Method meth = clazz.getMethod( "valueOf", new Class[]{ String.class });
              o[i] = meth.invoke( null, new Object[]{ split[i] });
         //here convert Object[] to Object of type int[] or double[] etc...
         /* and return that object*/
         //NB!!! I want to avoid the following code:
         if( o instanceof Integer[] ) {
              int[] ar = new int[o.length];
              for (int i = 0; i < o.length; i++) {
                   ar[i] = (Integer)o;
              return ar;
         } else if( o instanceof Double[] ) {
         //...repeat "else if" for all primary types... :(
         return null;
    Unfortunately I was unable to find any useful method in Java API (I work with 1.5).
    Did I make myself clear? :)
    Thanks in advance,
    Pavel Grigorenko

    I think I've found the answer myself ;-)
    Never thought I could use something like int.class or double.class,
    so the next statement holds int[] q = (int[])Array.newInstance( int.class, 2 );
    and the easy solution is the following -
    Object primeArray = Array.newInstance( token.getPrimeClass(), split.length );
    for (int j = 0; j < split.length; j++) {
         Method meth = clazz.getMethod( "valueOf", new Class[]{ String.class });
         Object val = meth.invoke( null, new Object[]{ split[j] });
         Array.set( primeArray, j, val );
    }where "token.getPrimeClass()" return appropriate Class, i.e. int.class, float.class etc.

  • How to create an array with controls and indicators?

    I want to create a scrollable array of control/indicator pairs from a config file.  Something that looks like the attached image.  Of course, I can only create an array that's either either a control or indicator -- not both (the operator should not be able to edit the name or change the state of the LED).  So I guess I need to split the array and have two side-by-side and SOMEHOW link the scrollbars.  But then I have no idea how I can get the control switch states from the array.  Is there an easier way to do what I'm trying to do?
    Attachments:
    New Bitmap Image.JPG ‏11 KB

    Hello,
    Another option would be to use the custom control I built for you, see below.  You can just drop this into an array, it should look like your example (more or less).
    Cheers!
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
    Attachments:
    Custom Switch.ctl ‏8 KB

  • Divide an array into components

    Hello:
    I am developing a LV application that has, in some way, "two parts": One of them is the user interface and its associated block diagram, that receives values from controls and files. Then, this values are used for feeding the inputs of a "Call Library Function" node.
    Well, some of the values I use are components of an array. I thought that I could use a "Split array" block, but I cant connect the "1 component array" with the numerical input of the library node.
    How could I "convert" a "1 component array" into a "numerical value". I actually use a very improper method, I connect the "1 component" array to a "array max & min" block, and I use "max value" output (I could use min too, obviously).
    Another question that is related to this is the follwing: Is there any method in order to split an array into its numerical components? Because I have, for example, a 4 elements array, I wished to divide it (in an easy way, instead of having a "serial association" of 4 "split array" blocks) into 4 numerical values that are used for feeding a function node.
    Well, if you need any aditional info, please dont hesitate in ask for it. Thank you very much for your attention and please sorry for my bad english.
    Yours sincerely.
    Juan Crespo

    Juan,
    Apologies if I misunderstood, but is the 'Index Array' function the answer to both your questions?
    =====================================================
    Fading out. " ... J. Arthur Rank on gong."
    Attachments:
    Index Array Elements.jpg ‏12 KB

Maybe you are looking for

  • Trouble creating a open items report (BSID and BSAD tables)

    Hi guys, im creating a report that must display open items for an especific date, and i do it very well with a query from BSID table. The problem comes when u use a date on the past, example last week. if u do that, the items are now closed and are n

  • Advice needed please

    Hello there, New to the forum and cannot find help anywhere else. I have lost the calculator software and cannot reinstall/retrieve it. Also, any software I try to install doesn't work - HotSync stops and says the application wasn't responding to Hot

  • Transfering data from External SQL database to BW

    Hi Experts,      I am trying to extract data from an External SQL Database  in BW using            DB Connect.     1. I have created a  DB Source System.     2. Using this Source System I have generated a Datasoure.        ( following all the naming

  • Chapters in book switch places on their own

    My teammates in our Tech Pubs group were just discussing an issue that we have each experienced at least once or twice... the chapters in our book somehow get out of order - on their own... usually only one or two are out of place.. but they somehow

  • The wifi is always connected even when screen is off.

    The wifi is always connected. Earlier the wifi connection used to get disconnecetd after few minutes if phone is not used. I wish which of the settings are to be used so that wifi gets off automatically if phone is not used.