Manipulati​ng 2D arrays

I'm fairly new to labview and working on a VI that I am taking over.
The VI has channels 0-31 (channels 0-3 are being used for a photo sensing diode).  In a while loop I am oversampling data at 1000 points/sec and the plan is to average 1000 pts and plot only the average per second.  I have a 2D array being piped out of the DAQmx Read (Analog 2D DBL NChan NSamp).  I am assuming the 2D array is the channel numbers and the data for each iteration.  I figured I'd transpose the array (to get the channel numbers in a row so I can isolate it), take 2 array subsets, one with index 0 and length 1 (I think this is wrong but I figured I would just get the first row and only the first row, but I seem to get an output of a 2D array), and the other with index 4 (since I don't want the photo diode channels) with no set length so it will take all the remaining data values.  Then I transposed the latter array so I can take averages of the elements.  I am thinking I get a column of averages of channels 4-31.
So now I have a row of my channels from 0-31 and a column of averages from 4-31.  The data needs to be thrown back into a 2D array to be written to the file.  Currently the output of the DAQmx is split and piped to an index array function that sends the photodiode channels to lock-in amps and straight down to be written to the file.
What can I do?  I am confused and obviously don't know enough to complete my task.  Any help is greatly appreciated.
Attachments:
average problem.JPG ‏205 KB

First off, I didn't create this VI, so I am really confused as to what is going on.  So I agree.  And the picture was just to show where I am starting from.  My ideas haven't been implimented, for reasons such as...I don't know much of what I'm doing.  I know it's a pain when someone as new to labview as I am posts questions.  The person who worked on this VI moved and it's part of an ongoing research project.  So a newbie like me was thrown into it, and it's a steep learning curve!  The data that is split out of the DAQmx (that just goes down to the file) is what I need to average.  I expected a 1D array of just one data point per channel to come out of the DAQmx but I get a 2D array.  So I am really confused.  Thanks for looking at it anyway.  I don't think I can really say much more other than the basics that I just need to take that 2D array and average the oversampled data.  One application is that we are taking temperature data and there is a lot of noise so we need to average those channels.  And since the other channels will be used eventually, we just wanted to average each channel, and throw it back into a 2D array.
I can post the VI when I go back to the lab tomorrow if that might help, but I'm quite lost.
thanks again,
nathan

Similar Messages

  • Manipulati​on of Array Data

    I would like to be able to manipulate some data (columns 2 and 3 of txt file) that I am collecting as a function of time (column 1 of txt file).
    Right now, as the VI is running, this data is being plotted on a waveform chart and saved to txt file.
    What I need to do is:
    Column 1 - Convert each time point to a wavelength.  I know starting wavelength (nm) and rate of change of wavelength (nm/sec).  I do this conversion on an excel spreadsheet right now where [current wavelength = previous wavelength - rate of change of wavelength*(current time-previous time)].  So how do I extract column one, take the difference between the second value and the first value, and create a new column (somewhere) corresponding to wavelength?  And save to a new column?
    Column 2 - Need to divide each value by 100 and subtract by a "baseline" (an average of the first 20 points, for instance).
    Column 3 - As is.
    Final step - Write to file a new column defined as manipulated column 2 divided by column 3 times 100...and then plot this (on y-axis) as a function of manipulated column 1 (x-axis). 
    It's not incredibly critical that the data manipulation occur in real-time...it can happen after the file has been written if necessary.  The final graphical result should look like the attached jpeg.
    Thanks in advance for the help - I'm a little uncertain about array conversion, unbundling, etc. nevermind the mathematical differences and averages that need to be obtained.
    Meredith
    Solved!
    Go to Solution.
    Attachments:
    Example Spectrum.jpg ‏36 KB
    Example Spectrum Data.txt ‏323 KB

    hello,
    i tried to make what i understood , see if it make sense
    few textual details in vi, two jpg attached in case your 're not LV8.6
    look at xy result to see if that talk to you , not for me 
    Best regards 
    Tinnitus
    CLAD / Labview 2011, Win Xp
    Mission d'une semaine- à plusieurs mois laissez moi un MP...
    RP et Midi-pyrénées .Km+++ si possibilité de télétravail
    Kudos always accepted / Les petits clicks jaunes sont toujours appréciés
    Don't forget to valid a good answer / pensez à valider une réponse correcte
    Attachments:
    spectrum.vi ‏21 KB
    spectum_code.jpg ‏131 KB
    specto_xy.jpg ‏123 KB

  • Manipulate 2-D arrays

    I need to add several 512 by 512 arrays and do arithmetic manipulations on them(multiply, divided, etc).  these arrays are 16 bit unsigned short and I am afraid that some of the entries will overflow as I add on more arrays, how do I get around this problem?
    Can a computer learn how to program?

    You could convert them to DBL at the beginning, using the conversion bullet.
    (For division the output will be DBL anyway)
    Message Edited by altenbach on 12-16-2005 09:39 AM
    LabVIEW Champion . Do more with less code and in less time .

  • Write an object that has array

    I am trying to figure out how to write a object with an array
    Player[] jim = new Player[30];
    for (int i=0;i<30;i++)
    jim= new Player("" + i);
    I am trying to figure out how to get the number of points jim scores in a month, so i need 31 days and a way to input the number of points he scored. Any help would be great

    Well, i think you don't have to create a whole bunch of arrays to enter jim's scores in 31 days. I presume you already have a separate object called Player. Why not set a List attribute on that object and manipulate the scores there. You don't need to instantiate an array for that.
    public class Player{
        private List scores = null;
        ....... //other attributes here
        public Player(){
            scores = new ArrayList();
        public void addScore(String score){
            scores.add(score);
        public List getScore(){
            return scores;
    }well, of course to get the contained items from the List, do manipulate it using arrays. And well, just parse down the returned scores to int because they are stored as strings here.
    hope that helps.

  • Efficient (Semi) Large Array Data Set Manipulation

    Hi Everyone.
    I am trying to figure out the most efficient way to manipulate somewhat large array of data (up to about 120 Megabyte) that I am currently getting from a FPGA. This data represent an image and it need to be manipulated before it can be displayed to the user. The data need to be unpacked from a U64 to I16 and some of it need to be chopped (essentially chop off 10% on each side of the image so if an image is 800 x 480 it becomes 640 x 480).
    I have tried several approaches and the image below show the one that is the quickest but there might be further optimization that could be done.
    I am looking forward to see what other can come up with.
    Note 01: I am including a link to the benchmark VI that has a quite large image in it so this VI is about 40MB.
    Note 02: this is cross-posted on Lava
    Thanks
    Attachments:
    BenchmarkImageDataManipulation.png ‏68 KB

    johnsold wrote:
    Using Array Subset rather than Reshape Array to truncate the 1D array is faster: 151 ms compared to 175 ms. 
    Lynn
    Thanks Lynn, this is good to know!
    Unfortunately the solution in this frame is still about 2x slower than the faster one (the "Reshape & Chop & Reshape & Unpack & Reshape").
    PJM

  • Director Array to Flash Array?

    I'd like to be able to create an array in Director, and then
    pass that array object into Flash and use it there. I can use
    Director to manipulate a Flash array, but I haven't been successful
    in passing an array object.
    Any help?

    If you have the new (at least more recent) Director 10.1
    update with the
    new Flash Asset Xtra, you can use the brand spankin new
    convert() method
    to do just that.
    Here is a technote (pdf) about how to use it:
    http://www.adobe.com/support/director/flash_8_asset_xtra.pdf

  • Bug in Tabular form Not Exist Validation, fails when creating multiple rows

    Hi,
    I have a Not Exist validation created for a Tabular form:
       select 1 from my_table where col1 = :col1 and col2 = :col2Execution State: For created and Modified Rows
    which is working fine when a row already there in DB
    and I am trying to enter a new row with same data.
    but when there's no data and I enter two rows with same data, validation does not fire, first row should allowed to enter
    but for second row it should give error that data already exists, which is not happening.
    for example,
    let's say I have a row in DB with: 1, 2, 3
    when I try to add a new row with same data ie. 1, 2, 3 validation fires and showing error, which is fine.
    but let's say there's no data in DB and I am entering two rows with:
    1, 2, 3
    1, 2, 3
    validation is not working this time, it is allowing to enter both the rows.
    do I need to create a manual validation for this or what?
    Apex 4.1.1.00.23
    Regards,
    Tauceef
    Edited by: Tauceef on Dec 6, 2012 10:09 AM
    Edited by: Tauceef on Dec 6, 2012 11:22 AM
    Edited by: Tauceef on Dec 6, 2012 11:27 AM

    Hello Tauceef,
    >> Now I got it, I was under impression that it will validate one by one row before insertion,
    >> but it's going to check all the rows first, then do the insertion.
    Just to clear things up, the APEX engine works exactly as you describe, but this is your problem.
    The APEX engine do check\validate all the rows first, one row at a time, and only if all the rows pass validation, the DML processes kick in. The DML processes work on the entire Tabular Form record set (per page view, of course).
    In order for your type of validation to work (the one that queries the database), as you want it, the validation and DML actions have to run together, row by row. This is not how things work, because it’s less efficient/optimal, and may lead to a situation where a certain row can fail validation, but other row(s) already been inserted/updated/deleted into/from the database. This could be a very tricky situation.
    Vikram has suggested to rely on a database constraint, and control the APEX error message. This is possible, although I’m not sure that in this case, the Tabular Form will retain all the user changes, in case of validation error. You should check it.
    Another option, which Marc hinted on, is to manipulate the G_Fxx arrays. In your case, you should loop through the new rows, compute their MD5, and make sure that all the rows have different MD5 values. This is on top of the current validation, which makes sure that the new rows do not already exist in the database.
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • Waveform CHart

    Hai Friends
                        I have an one doubt in Waveform Chart.How Programatically add the plots in the chart and How to update the values for newly added plots.
    Regards
    Jai
    Jayavel
    Solved!
    Go to Solution.

    You can't change the number of plots without loosing the data history. You could read the chart history property then manipulate the 2D array, add the new data, then update the history data again. A simpler alternative if you know the maximum number of channels you are likely to need, is to set up a dummy 1D array of NaN's then when you get your data, use 'Replace Array Subset' vi to add your variable data to the chart. Take a look at my example.
    Hope this helps.
    Ian 
    Attachments:
    Variable Plots.vi ‏19 KB

  • Possible pagination bug in tabular form

    Hi All,
    Can someone reproduce the following test case on 1.6.1.00.02?
    1. Create a tabular form via wisard
    2. Set pagination type 'Row Ranges in select list (with pagination).
    3. Set 10 rows per page
    4. Insert 11 rows
    5. Delete last row from the second page.
    The form should show no rows and 'Previous' link is missed.

    Hello Tauceef,
    >> Now I got it, I was under impression that it will validate one by one row before insertion,
    >> but it's going to check all the rows first, then do the insertion.
    Just to clear things up, the APEX engine works exactly as you describe, but this is your problem.
    The APEX engine do check\validate all the rows first, one row at a time, and only if all the rows pass validation, the DML processes kick in. The DML processes work on the entire Tabular Form record set (per page view, of course).
    In order for your type of validation to work (the one that queries the database), as you want it, the validation and DML actions have to run together, row by row. This is not how things work, because it’s less efficient/optimal, and may lead to a situation where a certain row can fail validation, but other row(s) already been inserted/updated/deleted into/from the database. This could be a very tricky situation.
    Vikram has suggested to rely on a database constraint, and control the APEX error message. This is possible, although I’m not sure that in this case, the Tabular Form will retain all the user changes, in case of validation error. You should check it.
    Another option, which Marc hinted on, is to manipulate the G_Fxx arrays. In your case, you should loop through the new rows, compute their MD5, and make sure that all the rows have different MD5 values. This is on top of the current validation, which makes sure that the new rows do not already exist in the database.
    Regards,
    Arie.
    &diams; Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.
    &diams; Author of Oracle Application Express 3.2 – The Essentials and More

  • A Programming Problem I am stuck on

    Hello,
    I am trying to solve the following problem:
    Given a deck of nCards unique cards, cut the deck iCut cards from top and perform a perfect shuffle. A perfect shuffle begins by putting down the bottom card from the top portion of the deck followed by the bottom card from the bottom portion of the deck followed by the next card from the top portion, etc., alternating cards until one portion is used up. The remaining cards go on top. The problem is to find the number of perfect shuffles required to return the deck to its original order. Your function should be declared as:
    static long shuffles(int nCards,int iCut);
    find the solution of shuffles(1002,101)
    So my code, which is pasted below, is a brute force method of solving the problem in that I am passing the entire array symbolizing a unique deck, to a shuffles function then using for loops to shuffle the deck and pass back the array and use for loops again to check if it matches the original deck. My code works for smaller cases but the (1002,101) case, is taking way too long and there is a solution that can solve the problem within a few minutes, I just need to figure it out.
    I am thinking rather than passing the entire array, perhaps i need to pass by reference to my shuffles function and use pointers to manipulate just one array and then use a for loop to check it. However, I am also trying to think of other reasons my code is too slow.
    Any help is really appreciated.
    srahan.
    -------------------------My Code in Java----------------------------
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    //import java.util.Arrays;
    public class Shuffles
    public static int ncards;
    public static int icut;
    public static long counter;
    public static void main (String[] args)
    long total=0;
    ncards = 102;
    icut = 11;
    counter = 0;
    //arrays for original card decks this stays the same order
    int[] deck = new int[ncards];
    int[] deck2 = new int[ncards];
    int[] ogdeck = new int[ncards];
    //create original card deck with unique cards, assume 0 is bottom of deck
    //and create initial shuffled deck instance
    for (int i=0; i<ncards; i++)
    ogdeck[i] = i;
    deck[i] = i;
    System.out.println("ncards: " + ncards);
    System.out.println("icut: " + icut);
    boolean equal=false;
    do
    deck2 = shuffledeck(deck);
    //equal = Arrays.equals(deck2, ogdeck);
    /* System.out.println("");
    System.out.println("ogdeck"); //print out original deck used for testing
    for (int i=0; i<ncards; i++)
    System.out.println(ogdeck);
    System.out.println("");
    System.out.println("deck2"); //print out shuffled deck used for testing
    for (int i=0; i<ncards; i++)
    System.out.println(deck2[i]);
    for (int i=0; i < ncards; i++)
    if (ogdeck[i]==deck2[i])
    equal = true;
    else
    equal = false;
    break;
    while (equal==false);
    if (equal == true)
    System.out.println("");
    System.out.println("It took " + counter + " perfect shuffles to return the deck to its orginal order");
    //shuffle function
    public static int[] shuffledeck (int[] decktoshuffle)
    int[] tophalf = new int[ncards];
    int[] bottomhalf = new int[ncards];
    int temp=0;
    int place=0;
    //cut passed deck into two halfs
    for (int i=0; i < (ncards-icut); i++)
    bottomhalf[i] = decktoshuffle[i];
    for (int i=(ncards-icut); i < ncards; i++)
    tophalf[temp] = decktoshuffle[i];
    temp++;
    //create new deck by shuffling
    //if the bottom half has LESS cards than top half
    if ((ncards-icut) <= icut)
    for (int i=0; i<(ncards-icut); i++)
    decktoshuffle[place]=tophalf[i];
    decktoshuffle[place+1]=bottomhalf[i];
    place=place+2;
    //place remaining cards from TOP half on top of new deck
    for (int j=(ncards-icut); j<icut; j++)
    decktoshuffle[place] = tophalf[j];
    place++;
    //if the top half has LESS cards than bottom half
    if ((ncards-icut) > icut)
    for (int i=0; i<(icut); i++)
    decktoshuffle[place]=tophalf[i];
    decktoshuffle[place+1]=bottomhalf[i];
    place=place+2;
    //place remaining cards from TOP half on top of new deck
    for (int j=(icut); j<(ncards-icut); j++)
    decktoshuffle[place] = bottomhalf[j];
    place++;
    counter++;
    return decktoshuffle;

    so i consolidated the two functions into one main function but its still too slow....any help would be appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    //import java.util.Arrays;
    public class Class1
         public static int ncards;
         public static int icut;
         public static long counter;
         public static void main (String[] args)
              long total=0;     
              ncards = 1002;
              icut = 101;
              counter = 0;
              int[] shuffdeck = new int[ncards];
              int[] currdeck = new int[ncards];
              int[] deckpointer = new int[ncards];
              int[] ogdeck = new int[ncards];
              //create original card deck with unique cards, assume 0 is bottom of deck
              //and create initial shuffled deck instance
              for (int i=0; i<ncards; i++)
                   currdeck[i] = i;
                   ogdeck[i] = i;
              System.out.println("ncards: " + ncards);
              System.out.println("icut: " + icut);
              boolean equal=false;
              int i;
              int j;
              int k;
              do
                   //i counts through top portion (of nCut cards)
                   //j counts through bottom portion (of nCards-nCut cards)
                   //k counts through new shuffle deck
                   //You can keep track of whether its back to normal during this process to save on time.
                   //We start with a deck with 0 on bottom and nCards-1 on top.
                   equal=true;
                   for(i=(ncards-icut), j=0, k=0; i<ncards && j<(ncards-icut); i++, j++, k+=2)
                        //Take from bottom of Cut
                        shuffdeck[k] = currdeck;
                        //Take from bottom of other half
                        shuffdeck[k+1] = currdeck[j];
                        if ( shuffdeck[k] != k )
                             equal = false;
                   //Add remaining cards to deck ( only one of two loops will be entered )
                   while ( k < ncards )
                        shuffdeck[k] = currdeck[j];
                        if ( shuffdeck[k] != k )
                             equal = false;
                        j++;
                        k++;
                   deckpointer = currdeck;
                   currdeck = shuffdeck;
                   shuffdeck = deckpointer;                         
                   counter++;
                   while (equal==false);
              if (equal == true)
                   System.out.println("");
                   System.out.println("It took " + counter + " perfect shuffles to return the deck to its orginal order");

  • OBPM Studio newbie 101 question - how do I manipulate arrays ?

    Hi :-)
    I've RTFM'd but couldn't find the answer so here goes.
    I'm using Java syntax and would like to manipulate my array like so:
    String[] foo = new String [  100  ];
    Unfortunately the above gets flagged as an error and I have no clue why. If I separate the above into two statements then I get the following results:
    String [] foo; <-- ok
    foo = new String [ 100 ] <-- error
    Using a static array e.g. String[] foo = { "foo" } is not an option for me because the array size can be variable.
    I must be missing something fundamental here ... appreciate your guidance pls. :-) Thanks
    PS: Somehow the left and right square brackets are stripped out from my post

    Hi,
    I would like to comment something.
    When you create a String array, behind the scenes, bpm is using a list. That's why you can not specify the array size.
    You can add elements in the following way:
    String[] arr;
    arr[] = "Fisrt element";
    arr[] = "Second element element";
    display(arr.toString());
    Hope this helps,
    Ariel

  • How to manipulate arrays using case statements and boolean conditions?

    In the vi that is attached I am trying to compare two values in two different arrays and delete the value that is equal to zero.  The values of each array are rounded to the closest integer.  Then I attempted to apply the ">0" boolean as the condition for my case statement, but I am getting an error.  Any tips on manipulating arrays with case statements?
    Attachments:
    Patient Movement Monitoring.vi ‏141 KB

    Thank you!!! that was a huge help. I don't think I need the case structures at all.  The next part of the code compares the 4 values in the array. 
    If columns 0 and 1 are both positive -> output 1
    If column 0 is negative and 1 is positive -> output 2
    If columns 0 and 1 are both negative -> output 3
    If column 0 is positive and 1 is negative -> output 4
    (0 is x-axis value, 1 is y-axis value.....outputs are assigning quadrants to the combination)
    Only one of the "AND" booleans will return true for each index.  Is there a way to initialize another array of outputs 1-4 depending on which AND returns true?
    Attachments:
    Patient Movement Monitoring.vi ‏144 KB

  • Using an array to manipulate SMC100 stage position

    Hi, 
    I am new to labVIEW. I am trying to take an image at various positions with the stage so I have to make create an array which I am not sure how to do it. For example, I want the stage to move from 10 ps - 1ps (in 1ps interval),  from1 ps - 2ps (in 100 fps interval) and from 2ps - 5ps (in 1ps interval) then when I run the program it will automatically does according to the array. Any thoughts how can I do this ? 
    Many thanks in advance,
    sdozai 

    You don't need to initialize the camera or the stage with each loop. You can move that outside of the loop. You also don't need the sequence structure since your data flow should make everything run in order.
    There are a lot of different way to set up this VI and you're not really doing it just right, but I'm not sure exactly how you want it to operate. Since you're new to LabVIEW, you could two one of two things. You can stumble through this VI and make it work by adding Wait nodes in there, or you can go research LabVIEW programming techniques to become more familiar with the programming practices. There is a 3 hour video and a 6 hour video on the basics, I suggest you take a look.

  • Array manipulati​ons...

    Hi
    I would like some help with array manipulation
    I have multiple  files (1000 text files) with 5 columns each and 20,000 rows. The first row of each file has a header that labels the columns.
    I would like to be able to read each of these files, pull out colum 3 from each file and then build these into a new 2D array. It would be nice if they also had their corresponding header labels. So then I would end up with the new 2D array containing 1,000 columns (corresponding to column 3 of each of my 1000 files) with 20,000 rows plus a first row with the header labels.
    I would also like the option to in future select column 2 for example, or column 5; plus I would also like the functionality to allow me to perhasp pull out more than one colum, e.g. colum 2 and 3, before we build the new array.
    I hope I made some sense and that someone can help. Thanks you

    Oh nuts! 
    While I was trying link those posts to give a heads up to the forum I had a sinking feeling that I was going to get it all wrong.
    I need to be more mindful of my feelings ....
    cheers
    David

  • Array Allocation and Memory

    I can create this array without a problem:
    private float[][][] floats = new float[170][170][170];
    This one causes an error:
    private float[][][][] floats = new float[170][170][170][1];
    Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: Java heap space
    I am using -J-Xms350m and -J-XX:MaxPermSize=500m
    Setting Xms350m to 400 stops Netbeans from starting, even though I have 3GB ram, and 50% of my physical memory is available according to taskmanager.
    I need to have three of the following array:
    private float[][][][] floats = new float[169][169][169][15];
    How can I do this so that the program will run in JVM?
    Do I have to switch to another language, such as C, for this?
    I actually do need to use all of this memory at once. There is nothing that I can do to reduce it. I have millions of unique values to store and manipulate.

    cyzo wrote:
    Its "The only IDE you need."
    I can run netbeans with "-J-Xss2m -J-Xms128m -J-Xmx1000m -J-XX:PermSize=32m -J-XX:MaxPermSize=512m"
    I still get the heap size error.-Xmx1000m is for your java application and not for the NB ide. Did you get me correct?
    $>java -cp yourClassPaths -Xmx1000m yourJavaApplication

Maybe you are looking for