Efficiently accumulating arrays

Hello,
I am attempting to acquire a reasonable amount of data (between 100000
and 1000000 floats) that I would like to accumulate into an array of
single-precision floats.
Efficiency is important due to time requirements of the device that I
am acquiring from.
I have observed that using a large array size - such as those
mentioned above - results in my program running considerably slower
throughout. The array is pre-allocated to the correct size using
"Initialize Array" and then elements are replaced one-by-one using
"Replace array Subset". This I believe to be the most efficient way
of doing it from what I have read, for example in:
http://zone.ni.com/devzone/conceptd.nsf/2d17d611efb58b22862567a9006ffe76/979f737147fd5c01862569f3
00638674?OpenDocument
Figure 2 on that page is quite similar to what I have (although much
simplified). For each iteration of the loop I have my array wired to
"Replace Array Subset", with the output wired to a local variable of
the input array.
Is there any reason why Labview should perform so poorly with large
array sizes? My suspicion is that a copy of the entire array or a
size check is being performed somewhere, but neither should be
necessary in this case.
If anyone could offer advice as to how to accumulate data into an
array more efficiently I would be most grateful.
I am using Labview 6.1
Regards,
Stephen

> being received in blocks of 20 bytes which I then cast to a U32 array
> so that I can "Byte-Swap" and "Word-Swap" before casting to
> single-precision floats to extract the 5 floats which are the real
> data. Each float is then appended to an array (since each of the 5
> floats represents a different value) and then the 5 arrays are passed
> to the next iteration using shift-registers as suggested by Mads.
>
> I am aware that casting is inefficient in Labview as it makes a copy
> of the data(?), but it seems unavoidable in this case as I must
> perform byte-swapping and Labview will only byte-swap integers, even
> though I really want a byte-swapped float! I could move the
> byte-swapping out of the acquisition phase, but this should be a
> linear problem and so would not cause my program to slow down as it
> does.
It is probably just terminology, but here are some comments. After
casting your 5 U32s to 5 floats, you say you extract the data and append
it to an array. If you are truly using build array, then you are
resizing the big array each time through the loop.
Here is what you should try instead. Before starting the loop use
Initialize Array to build a suitably sized buffer of zeros or other
initialized value and wire that to your shift register. Inside the loop
use Replace Array Subset to put all five floats from your array into the
large array at the correct offset, or in older LVs, use five index nodes
and five replaces, or use a for loop that autoindexes your small array,
running five iterations, and does an Element Replace on the large array
at the correct location.
If you don't know how much data will arrive before entering the loop,
then take a guess and inside the loop extend the array using Reshape
Array once in awhile to add another couple thousand elements. You will
also need to shrink the array after the loop, again using reshape.
The key here is that resizing a big array gets more and more expensive
as it gets larger. If you resize the array each iteration of the loop,
this is far more expensive than the occasional resize, say each 1000
elements, which is still more expensive that one resize before the loop
begins.
If this doesn't help, it might help if you were to post the VI or a
picture of the VI diagram.
Greg Mckaskle

Similar Messages

  • Howto efficiently Copy array into data portal

    I have an array in VBS memory and would like to create an channel in the data-portal based on that data-set, I currently use this code construct to copy the data:
    ' intChannelCount is the number of samples
    'MaxHold is the data array to be copied
    'oFFTMaxHold is the data channel that is the target of the data
    for counter = 1 to intChannelCount
          oFFTMaxHold.Values(counter)=MaxHold(counter)
    next
     It is rather slow (and if the data preview is open in the data portal) even much slower.
    Is there a method to copy the whole array in one operation to a channel?
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Solved!
    Go to Solution.

    Hi Ton,
    If you have DIAdem 10.2 or later you can use the following command to do this with one command-- passing the array of values as one of the command's parameters-- this is a common situation when querying records from a data base that you want to load into the Data Portal as channels.
    ChanRefsArray = ArrayToChannels(ValuesArray, ChanNamesArray)
    In the case of your example below, that would be:
    Call ArrayToChannels(MaxHold, Array(oFFTMaxHold.Name))
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Efficient Int32 Array to Boolean Array to Int16 Array

    Have a large array of Int32 (~500,000 elements).
    Each Int32 needs to be parsed into two Int16 arrays: Array 1 is the first 12 bits of the Int32, Array 2 is the second 12 bits of the Int32.
    The method I am using (see attached) works just fine but it is taking a lot of time to run (on a relatively slow, embedded CPU).
    Does anyone have an idea how to make this run faster?
    Solved!
    Go to Solution.
    Attachments:
    Example Code.rtf ‏571 KB

    Red Sox Fanatic wrote:
    Excellent - thanks I'll give it a try!
    Not that you needed more ways to solve this problem, but lots of us on this board are curious about performance and I had a few minutes to throw together a VI to test the timing of a few approaches suggested here, as well as two variations of an additional approach that I like (shown here).  The basic conclusion is that they're all pretty close on my machine (LV 2009).  Splitting a 1-million element array, averaged over 50 times, the approach with 2 ANDs was 20ms.  Using a FOR loop was 21ms.  Using a pair of shifts (shown below) was 17ms.  A variation of this, with a typecast, was much slower, at 35.5ms.
    Attachments:
    2x12 bits from 32.vi ‏19 KB

  • Casting Arrays

    Is there anything particularly bad with casting Arrays? For convenience, I store some instances of a class in a LinkedList. Now, when I want to get them in a nice Array, I tried this:
    ("Creature" being a class of mine)
    Creature[] creatureArray = (Creature[]) CreatureList.toArray();That resulted in a splendid ClassCastException.
    However, this works:
    Object[] creatureArray = CreatureList.toArray();
    for (int i = 0; i < creatureArray.length; i++)
        Creature name = (Creature) creatureArray;
    So, is there generally a problem with casting Arrays or is there something else that might be the problem?
    Thank you for any suggestions!

    This may be more be more efficient:
    Creature [] array = (Creature[]) creatureList.toArray( new Creature[creatureList.size()] );

  • Performance problem with graphs on Tabs (LV7.1)

    I have huge performance problems in a subsystem using tab controls with graphs on top. The whole thing worked nice, until I record a measurement (abou 10k of double as data displayed on the graph). The win task manager indicates above 50% on both CPUs, the app hangs (or lags), my queues generate timeout messages...
    The graph is located in one of the pages of a tab control. As well are several clusters of config data for the measurement.
    As I said, the problems started, when I put the data of that size on the graph indicator.
    The clusters are some nested typ defs, but it worked with them before, no huge arrays involved. All are bundled in a huge cluster (less than 1 k if saved as xml).
    So I wonder, if the clusters and/or the graphs are the problem PLUS is that problem resolved in current LV-Versions (hoping to get the faster car & and I love the current GUI with tabs)?
    Sorry, can't post the code, but if none of you knows that kind of problems and I can't solve it on my on in an hour or so, I can make some imitation code.
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

    How many graphs are you referring to?
    Are they all on your User Interface and running in the UI thread?
    You might want to try putting your graphs in their own threads i.e., called dynamically or otherwise in a structure that allows LabVIEW to put them in their own thread. I've gotten good performance out of a PXI-8106 controller by calling a graph template dynamically. That's four graphs showing at once, 12 plots per graph, 10000 XY value pairs per plot. Each graph was setup to get its data every 50-200ms.
    How much data you can plot with decent performance also depends on the hardware you're using, i.e., CPU speed, RAM size, video capability, etc. It can also depend on how efficiently you've coded your application. Are you initializing your data arrays and using "Replace Subset" or are you using the less efficient "Build Array" for example?
    Message Edited by Bill@NGC on 09-11-2007 09:31 PM
    “A child of five could understand this. Send someone to fetch a child of five.”
    ― Groucho Marx

  • Data Flow Question

    I have a Air app where an employee creates an order. This stores the order information in an order arraycollection, they also add items in the order and those go in the orderitems arraycollection.
    Now because the employee may not always have a network connection I have made it so it caches the data in a stored object and an upload button to upload the orders.
    Currently I have it upload the order for each item in the orders arraycollection and return an allert if the add status returns true or false.
    Does anyone know of a way or seen a tutorial on how to grab the associated items based on the UID in the items array collection and upload those as well in flex?
    Also after the item has been uploaded I would like to remove thme from the array collection.
    Thanks for any help!

    Your post is very vague and I don't think you give enough information to really help.
    I am pretty familiar with LabVIEW, but terms like "spit out", "get serviced", and "continuously" have very little meaning without much more details.
    If you only plot the data if they are nonzero, you must already have a case structure. To build an array, all you need is a shift register initialized with zero and a build array node in one of the cases (the array is wired through unchanged in the other case). Make sure to select "concatenate array" mode for "build array". Of course if you continously append data, you will very quickly run out of memory, so you probably need some mechanism to deal wit that scenario. Do you want to only plot the current data or the entire accumulated array?
    I have no idea how the consumer loop can hold up the dataflow in the producer loop. Where is the dependency coming from?
    You don't need to upload a huge project. I am sure you can reduce it to a simple VI with two small loops and some random number generator. This would be enough to show the basic architecture you are using. Thanks!
    LabVIEW Champion . Do more with less code and in less time .

  • 10gR2 RAC on  Dell/EMC AX150

    I have a Fibre Channel Array say Dell/EMC AX150.
    I need to understand the following
    a. The Dell/EMC AX150 comes with QLOGIC QLE220 FC4 Single Channel HBA
    will I need "QLOGIC QLE220 FC4 Single Channel Two HBAs" for a 2-node RAC
    Will I need HBA for host servers too?
    b. Can i do a 2-node RAC without the Fibre Channel Switch
    Since
    http://www.oracle.com/technology/products/database/clustering/certify/tech_generic_linux_new.html
    says for the storage section
    "Switch required for greater than two nodes"
    c. Can i connect the HBA on the storage array to NIC1 of node1
    and HBA on the storage array to NIC2 of node2
    using the Fibre Channel Cables provided with the storage box
    Thanks
    Cyril

    Please let me know if you have managed to put in the production what you describe below. We are pretty much in the same situation right now, looking for a cost-efficient disk array solution for Oracle RAC. Based on the information I found on the Internet so far:
    "a" - you need those HBAs for the servers, which will be running Oracle RAC and accessing the disk array - so if you plan to have twp nodes in RAC, you do need two cards
    "b" - the answer seems to be "yes", but it looks like you may need "cross-over" fiber channels in this case (the Re: can fiber channel be used for connect server to a storage in two nodes RAC post - but looks like you've already seen that one and even replied :-) )
    "c" - I think you put HBAs into your servers, and then connect them with cables to your disk array (normally via switch - but see above).

  • Pacman now needs to change color, but the types are incompatible ...

    Hi, my book sucks and I need your help again , Thanks In Advance !!!
    OK, now pacman can move in all directions and make a random move, but there needs to be a button to make him change color...
    I have come up with the following code but when I try to compile I get incompatible types for my new Pacmancolors...
    package pacman;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Autopacman extends Applet implements ActionListener
    boolean Packleur1;
    boolean Packleur2;
    boolean Packleur3;
    boolean Packleur4;
    boolean Packleur5;
    boolean Packleur6;
    int klikken = 1;
    int x = 200, y = 200; //beginpositie pacman
    int width = 50, height = 50; //formaat pacman
    int stap = 20; //standaard stapgrootte
    int stapVerander = 10; //stapgrootte wijziging
    int angleA = 5; //beginhoeken pacman
    int angleB = 345;
    public void init(){
    Button links = new Button("links"); //knoppen worden gemaakt en gelabeld
    Button rechts = new Button("rechts");
    Button omhoog = new Button("omhoog");
    Button omlaag = new Button("omlaag");
    Button harder = new Button("harder");
    Button zachter = new Button("zachter");
    Button random = new Button("Random actie");
    Button kleur = new Button("Kleur veranderen");
    links.addActionListener(this); //action events worden aan knoppen gekoppeld
    rechts.addActionListener(this);
    omhoog.addActionListener(this);
    omlaag.addActionListener(this);
    harder.addActionListener(this);
    zachter.addActionListener(this);
    random.addActionListener(this);
    kleur.addActionListener(this);
    add( links ); //knoppen worden op canvas gezet
    add( rechts );
    add( omhoog );
    add( omlaag );
    add( harder );
    add( zachter );
    add( random );
    add( kleur );
    public void paint(Graphics g){
    g.setColor( Color.black);
    g.drawLine( 0, 34, 600, 34 );
    Packleur1 = g.setColor( Color.yellow );
    Packleur2 = g.setColor( Color.red );
    Packleur3 = g.setColor( Color.blue );
    Packleur4 = g.setColor( Color.green );
    Packleur5 = g.setColor( Color.white );
    Packleur6 = g.setColor( Color.black );
    g.fillArc(x, y, width, height, angleA, angleB); //teken de pacman voor het eerst
    public void actionPerformed(ActionEvent e){
    String str = e.getActionCommand();
    if( str.equals("Kleur veranderen")){
    klikken++;
    if( klikken = 2 )
    {Packleur2 = true;}
    if( klikken = 3 )
    {Packleur3 = true;}
    if( klikken = 4 )
    {Packleur4 = true;}
    if( klikken = 5 )
    {Packleur5 = true;}
    if( klikken = 6 )
    {Packleur6 = true;}
    return false;
    if(klikken == 7)
    {klikken = 1;}
    if( str.equals("Random actie") ){       //Die stomme random functie
    int i = (int)(Math.random() * 10);
    switch(i){
    case 1: case 7 : str = "omlaag"; break;
    case 2: case 8 : str = "omhoog"; break;
    case 3: case 9 : str = "links"; break;
    case 4: case 10 : str = "rechts"; break;
    case 5: case 0: str = "harder"; break;
    case 6: str = "zachter"; break;}
    if( str.equals("harder") ){ stap = stap + stapVerander;} //stap wordt 10 groter
    if( str.equals("zachter") ){ stap = stap - stapVerander;} //stap wordt 10 kleiner
    if( stap < 0){stap = 1;} //Stapgrootte wordt nooit negatief of nul
    if( str.equals("links") ){ x -= stap;     //linksknop laat pacman links kijken en bewegen
    angleA = 185;
    angleB = 345;}
    if( str.equals("rechts") ){ x += stap;    //rechtsknop laat pacman rechts kijken en bewegen
    angleA = 5;
    angleB = 345;}
    if( str.equals("omhoog") ){ y -= stap;    //omhoogknop laat pacman omhoog kijken en bewegen
    angleA = 95;
    angleB = 345;}
    if( str.equals("omlaag") ){ y += stap;    //omlaagknop laat pacman omlaag kijken en bewegen
    angleA = 275;
    angleB = 345;}
    if( x <= 0){ x = 0;} // houdt de pacman tegen als hij links/rechts wil verdwijnen
    if( x > 550){ x = 550;}
    if( y <= 35){ y = 35;} // houdt de pacman tegen als hij boven/onder wil verdwijnen
    if( y > 550){ y = 550;}
    repaint(); // zet de pacman opnieuw op het canvas
    Can anyone help me with this?
    Thanks a bundle!
    Menno.

    Thanks a lot!
    Say if you want to see how it works just compile this source :
    /* Autopacman spelletje
    Menno Hagens, I108
    2001
    Autopacman.
    Maak via overerving van de klasse Packman uit week 4 een nieuwe klasse 'AutoPackman'.
    Deze klasse moet de volgende extra functionaliteit bevatten.
    De kleur van de Packman moet kunnen worden ingesteld.
    Er moet een methode komen die een willekeurige opdracht aan de Packman geeft.
    (naarLinks, naarRechts, gaSneller, gaTrager, etc.)
    Maak vervolgens een applet met vier Packmannetjes en ��n knop 'Beweeg'.
    Als je op deze knop drukt, moeten alle Packmannetjes ��n stap in een willekeurige
    richting doen.
    Programmeer dit efficient met arrays en loops.
    Als je na afloop nog moed hebt kun je de klasse en de applet zo aanpassen dat een
    spel ontstaat, waarbij een Packman die op de positie van een andere komt, de andere
    Packman opeet. Degene die overblijft heeft gewonnen.
    package pacman;
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Autopacman extends Applet implements ActionListener
    boolean Packleur1;
    boolean Packleur2;
    boolean Packleur3;
    boolean Packleur4;
    boolean Packleur5;
    boolean Packleur6;
    int klikken = 1;
    int x = 200, y = 200; //beginpositie pacman
    int width = 50, height = 50; //formaat pacman
    int stap = 20; //standaard stapgrootte
    int stapVerander = 10; //stapgrootte wijziging
    int angleA = 5; //beginhoeken pacman
    int angleB = 345;
    public void init(){
    Button links = new Button("links"); //knoppen worden gemaakt en gelabeld
    Button rechts = new Button("rechts");
    Button omhoog = new Button("omhoog");
    Button omlaag = new Button("omlaag");
    Button harder = new Button("harder");
    Button zachter = new Button("zachter");
    Button random = new Button("Random actie");
    Button kleur = new Button("Kleur veranderen");
    links.addActionListener(this); //action events worden aan knoppen gekoppeld
    rechts.addActionListener(this);
    omhoog.addActionListener(this);
    omlaag.addActionListener(this);
    harder.addActionListener(this);
    zachter.addActionListener(this);
    random.addActionListener(this);
    kleur.addActionListener(this);
    add( links ); //knoppen worden op canvas gezet
    add( rechts );
    add( omhoog );
    add( omlaag );
    add( harder );
    add( zachter );
    add( random );
    add( kleur );
    public void paint(Graphics g){
    g.setColor( Color.black);
    g.drawLine( 0, 34, 600, 34 );
    g.setColor( Color.yellow);
    if( klikken == 1 )
    {g.setColor(Color.yellow);}
    if( klikken == 2 )
    {g.setColor(Color.red);}
    if( klikken == 3 )
    {g.setColor(Color.blue);}
    if( klikken == 4 )
    {g.setColor(Color.black);}
    if( klikken == 5 )
    {g.setColor(Color.green);}
    if( klikken == 6 )
    {g.setColor(Color.white);}
    g.fillArc(x, y, width, height, angleA, angleB); //teken de pacman voor het eerst
    public void actionPerformed(ActionEvent e){
    String str = e.getActionCommand();
    if( str.equals("Kleur veranderen")){klikken++;}
    if(klikken == 7)
    {klikken = 1;}
    if( str.equals("Random actie") ){       //Die stomme random functie
    int i = (int)(Math.random() * 17);
    switch(i){
    case 1: case 7 : case 11: case 15 : str = "omlaag"; break;
    case 2: case 8 : case 12: case 16 : str = "omhoog"; break;
    case 3: case 9 : case 13: case 17 : str = "links"; break;
    case 4: case 10 : case 14: case 0 :str = "rechts"; break;
    case 5: str = "harder"; break;
    case 6: str = "zachter"; break;}
    if( str.equals("harder") ){ stap = stap + stapVerander;} //stap wordt 10 groter
    if( str.equals("zachter") ){ stap = stap - stapVerander;} //stap wordt 10 kleiner
    if( stap < 0){stap = 1;} //Stapgrootte wordt nooit negatief of nul
    if( str.equals("links") ){ x -= stap;     //linksknop laat pacman links kijken en bewegen
    angleA = 185;
    angleB = 345;}
    if( str.equals("rechts") ){ x += stap;    //rechtsknop laat pacman rechts kijken en bewegen
    angleA = 5;
    angleB = 345;}
    if( str.equals("omhoog") ){ y -= stap;    //omhoogknop laat pacman omhoog kijken en bewegen
    angleA = 95;
    angleB = 345;}
    if( str.equals("omlaag") ){ y += stap;    //omlaagknop laat pacman omlaag kijken en bewegen
    angleA = 275;
    angleB = 345;}
    if( x <= 0){ x = 0;} // houdt de pacman tegen als hij links/rechts wil verdwijnen
    if( x > 550){ x = 550;}
    if( y <= 35){ y = 35;} // houdt de pacman tegen als hij boven/onder wil verdwijnen
    if( y > 550){ y = 550;}
    repaint(); // zet de pacman opnieuw op het canvas

  • The efficiency of data value references to avoid buffering arrays

    I would like to get NI's formal position on this question.  It was my understanding that DVR's of arrays are an efficient way of avoiding array copying when branching would ordinarily occur in their absence.
    This seems to be confirmed here:
    http://zone.ni.com/reference/en-XX/help/371361L-01/lvconcepts/external_data_val_ref/
    http://zone.ni.com/reference/en-XX/help/371599K-01/lvfpgahelp/fpga_zerocopy_dma/
    However, there appears to be some (very outdated) chatter with a contrary view:
    http://forums.ni.com/t5/LabVIEW/quot-Data-Value-Reference-quot-and-quot-In-Place-Element/td-p/155846...
    http://lavag.org/topic/10983-dvr-vs-pointer/
    There are normally lots of changes in LabVIEW from year to year; so if this contrary position was ever true, it may no longer be so. 
    Thanks,
    Jordan
    Jordan McBain, PhD
    LabVIEW Controls Engineer
    Revolutionary Engineering

    You messed up your last two links. They point to some outlook mail server!
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Most efficient way to strip nulls from a Double[] array?

    I'm trying to optimize performance of some code that needs to accept a Double[] array (or a List<Double>) and fetch the median of the non-null values. I'm using org.apache.commons.math.stat.descriptive.rank.Median to fetch the median after converting to double[]. My question is how I can most efficiently make this conversion?
    public class MathStatics {
         private static Median median = new Median();
         public static Double getMedian(Double[] doubles) {
              int numNonNull = 0;
              for (int i = 0; i < doubles.length; i++) {
                   if (doubles[i] != null) numNonNull++;
              double[] ds = new double[numNonNull];
              for (int i = 0; i < doubles.length; i++) {
                   if (doubles[i] != null) ds[i] = doubles;
                   System.out.println(ds[i]);
              return median.evaluate(ds);
         public static void main(String[] args) {
              Double[] test = new Double[] {null,null,-1.1,2.2,5.8,null};
              System.out.println(MathStatics.getMedian(test));
    I'm sure that the code I wrote above is clunky and amateurish, so I'd really appreciate some insight into how to make improvements. FWIW, the arrays will typically range in size from ~1-15,000 doubles.
    Thanks!

    There's no need to loop over the array twice
              int numNonNull = 0;
              double[] ds = new double[numNonNull];
              for (int i = 0; i < doubles.length; i++) {
                   if (doubles[i] != null) {
    numNonNull++;
    ds[i] = doubles;
                   System.out.println(ds[i]);
    Except that ds will have length zero, so you'll get a OutOfBoundsException every time you use it.
    As you're using Doubles rather than doubles, you can add the non-null values to an ArrayList and then convert it to an array at the end.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Most efficient way to pack U16 -- U32 Array for Data DMA Transfer?

    I have an RT controller that wants to send down data to an FPGA using DMA.  In LabVIEW 8.2, I have no choice but to pass down U32 blocks of data however my my input data is a U16 array.  This leaves me two choices:  1) Wire the U16 Array directly to the DMA node which will coarse it to U32 but I'm wasting 16bit*#of elements 2) Pack the U16 array into a U32 Array prior to sending it down.    I would like to do #2 and I have a method that works (and seems to be pretty efficient) but I have a feeling I am doing it the hard way (or roundabout way).   Is  their a simpler (but just as efficient) way to do this procedure?  Thanks
    Solved!
    Go to Solution.
    Attachments:
    ni1.gif ‏8 KB
    ni2.gif ‏10 KB

    SiegeX wrote:
    ... unfortunately I forgot to mention that byte order does matter and odd # of inputs are allowed.
    See, that something that does not make full sense here, because you end up with a mixed byte order, because the 16bit halves are still big endian. What's at the "other" end, exactly?
    Anyway, here's a slight simplification of the previous code. (The typecast is better if we can do it all big endian and omit the "decomate/interleave" dance.)
    (You could also flatten to a string and back. This has the advantage that byte order is a direct option. I don't know how that is, performance wise.))
    Message Edited by altenbach on 11-12-2008 04:31 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    typecasting3.PNG ‏4 KB

  • Build array efficiency

    Hello,
    I would like to know, wheather my solution is efficient, or it can be done in a better way.
    I have a mass spectrometer with a shipped labview driver and example VIs.
    I want to modify one of the VI. Here the used structure of the spectrum is a kind of waveform cluster. I have attached a non funcional only-test VI, to show it. For data evaluation, I need to use XY-data pairs, so I need to create X,Y arrays from this cluster type. The size of the arrays are in the order of 10 thousends... Just in case, I will use a queue wire to do the data evaluation (consumer loop) independent of the producer loop (about 0.5 Hz data production, so every 2 sec I get a new spectrum from the MS driver).
    So my question is that, is there a better way to create the XY arrays from that cluster type? Depending on the data size, in my experiance, this can be a bit slow...?
    Thanks for advice!
    dropbox link: (the discussion forum is not able to upload my VI... )
    https://dl.dropboxusercontent.com/u/8148153/test1.vi
    Solved!
    Go to Solution.

    I agree with the ramp function being a bit more efficient, but I am not sure about replacing array subset for building sequential numbers. I would be interested to learn if it was otherwise.
    The following post seems (I agree is old) seems to back up my understanding. I also did a quick benchmark and it seems to back my belief
    http://forums.ni.com/t5/LabVIEW/create-an-array-of-consecutive-integers/td-p/127751
    Beginner? Try LabVIEW Basics
    Sharing bits of code? Try Snippets or LAVA Code Capture Tool
    Have you tried Quick Drop?, Visit QD Community.

  • Most efficient coding method to get from WFM Digital to Timestamp Array and Channel Number Array - Earn Kudos Here !

    I'm Fetching data from a digitizer card using the niHSDIO Fetch Waveform VI.  After Fetching the data I want to keep the Timestamp and Digital Pattern which I'll stream to TMDS file.
    What is the most efficient method of striping out the Arrays I'm interested in keeping?
    The attached VI shows the input format and desired output.  The Record Length is always 1.  I'll be streaming 100,000+ records to file using a producer-consumer architecture with the consumer performing a TDMS write.
    I'm assuming only the WDT Fetch gives you the time from t0.
    Attachments:
    Digital Waveform to Array Coding.vi ‏11 KB

    Hi bmann2000,
    I'm not sure about efficiency but this method definitely works. I've just used a 'Get Digital Waveform Component' function and the 'Digital to Boolean Array' function.
    Hope this helps.
    Chris
    National Instruments - Tech Support
    Attachments:
    Digital Waveform to Array Coding 2.vi ‏15 KB

  • Reading information from multiple arrays efficiently

    So I'm trying to make a flash application about number of felonies of different trafic violations from different years, example:
    In 2002 there was 9631 drunk drivers, 13481 driving without a license, 9863 speeders and 18862 who broke other laws
    In 2003 there was 8593 drunk drivers, 12785 driving without a license, 12217 speeders and 19196 who broke other laws
    The list goes on and I've made 5 different arrays, one for year, one for drunk drivers, one for driving without a license,
    I call them:
    var arTab:Array = new Array();
    arTab[0] = new Array(2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012);
    var promilleTab:Array = new Array();
    promilleTab[0] = new Array(9631, 8593, 8363, 8128, 8514, 8534, 8560, 8146, 8241, 8019, 8759);
    var forerkortTab:Array = new Array();
    forerkortTab[0] = new Array(13481, 12785, 12585, 12492, 13470, 14181, 14622, 14082, 14287, 13640, 14180);
    var hastighetTab:Array = new Array();
    hastighetTab[0] = new Array(9863, 12217, 14920, 14929, 15425, 18010, 15909, 14197, 13276, 11158, 12264);
    var trafikklovenTab:Array = new Array();
    trafikklovenTab[0] = new Array(18862, 19196, 20101, 20026, 21381, 21845, 20005, 19446, 20900, 19346, 20265);
    After that I added 2 comboboxes, one for the year and one to pick felony, but when I try to write out the information in a text box I have to add ALOT of code, example:
    function skrivUt(Event:MouseEvent)
           var arListe:int = arKombo.selectedItem.data;
           var bruddListe:int = bruddKombo.selectedItem.data;
           if(bruddListe == 1)
                if(arListe == 1)
                txtSvar.text = "I " + arTab[0][0] + " ble det anmeldt " + promilleTab[0][0] + " for promillekjøring";
                if(arListe == 2)
                txtSvar.text = "I " + arTab[0][1] + " ble det anmeldt " + promilleTab[0][1] + " for promillekjøring";
                if(arListe == 3)
                txtSvar.text = "I " + arTab[0][2] + " ble det anmeldt " + promilleTab[0][2] + " for promillekjøring";
    And I would have to make tons of almost the same line which works, but my question is:
    Is there any way I can write this in a more efficient way?

    You could look for a pattern that follows your current code.  For what you show already I see...
    function skrivUt(Event:MouseEvent)
           var arListe:int = arKombo.selectedItem.data;
           var bruddListe:int = bruddKombo.selectedItem.data;
           if(bruddListe == 1)
                txtSvar.text = "I " + arTab[0][arListe-1] + " ble det anmeldt " + promilleTab[0][arListe-1] + " for promillekjøring";

  • What is the most efficient way to turn an array of 16 bit unsigned integers into an ASCII string such that...?

    What is the most efficient way to turn a one dimensional array of 16 bit unsigned integers into an ASCII string such that the low byte of the integer is first, then the high byte, then two bytes of hex "00" (that is to say, two null characters in a row)?
    My method seems somewhat ad hoc. I take the number, split it, then interleave it with 2 arrays of 4095 bytes. Easy enough, but it depends on all of these files being exactly 16380 bytes, which theoretically they should be.
    The size of the array is known. However, if it were not, what would be the best method?
    (And yes, I am trying to read in a file format from another program)

    My method:
    Attachments:
    word_array_to_weird_string.vi ‏18 KB

Maybe you are looking for

  • Firefox will not open with previous session. Option automatically resets to default.

    I set options to: "Show my windows and tabs from last time". But, when I start Firefox, it does not save this option and reverts to the default option. I've tired disabling add-ons and refreshing Firefox, but the problem still occurs. Troubleshoot re

  • Webdriver no longer works in Firefox 13.0.1

    I write Webdriver automation regression tests using the FirefoxDriver. The other day, firefox automatically updated itself, and as soon as it did, I could no longer run automation. I tried restarting my computer, reinstalling firefox- no help. Had to

  • Ipod does not hold charge

    My iPod Classic only holds a charge for 10 minutes. Can this be repaired?

  • XML Query error

    I create a table like: CREATE TABLE person_data ( person_id NUMBER(3), person_data XMLTYPE); Then I insert some data: INSERT INTO person_data (person_id, person_data) VALUES (1, XMLTYPE(' <PDRecord> <PDName>Daniel Morgan</PDName> <PDDOB>12/1/1951</PD

  • Change the color of the text in Display item

    Hi friends, Can I change the color of the text of text item or display item Regards, Fateh