How do i create arrays more efficientl​y

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

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

Similar Messages

  • How can i create a more detailed map in aperture?

    How can i create a more detaled map in Aperture- Book?

    There are no templates for more detailed maps in Aperture.
    You might consider to add more detailed maps as photos to the photo boxes in the book. I sometimes simply take a screenshot of the map in "Places" view to get a more detailed map with the pins marking the places.

  • How do you create array of enums for transitions in a state machine?

    Hello,
    I am trying to build a state machine, but, I am struggling with understanding the methods for determining which state to transition to next.  In other words, I have several states, but, I don't want to go in any particular sequence.  If I have states numbered 1 through 10, I want to be able to go 1-4-2-5-6-2-6-1-10 etc. in no particular order. I want the transition to the next state  (and actions) to be determined by the streaming data, which can be random and require access to any of my 10 states at any time and in any sequence.
    I saw this picture on the "Application Design Patterns: State Machines" white paper, but, it leaves out some important details.  How does one create the structure in BLUE shown in 3C?  When I try to create this array of enums, all of them are the same. I am not able to make a list of different enum values.  In other words, when I type in "2", then, all the values in the array display as "2."
    There is a nice, simple video example of a state machine for dispensing soda for $0.15, however, this state machine moves in a single sequence, from 5 cents, to 10 cents to dispense; it does NOT illustrate how to select a state "out of order."  I need to understand how a state machine can move from "5 cents" state to dispense directly, with the addition of 10 cents to the "5 cents" state.
    Can anyone suggest a really good tutorial on how to make the selector work in a state machine?  I have been reading some of the available material on ni.com, but, I can't find a good detailed explanation of how to do it.  I remain confused. 
    Or, can you just explain how they created the BLUE array in the attached picture?  Maybe I can figure it out from there.
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    next state.jpg ‏75 KB

    Hi Kathryn,
    Yes, this is EXACTLY what I want to accomplish...
    So it would basically run:
    State 1
    Read input
    Determine next state (say 3)
    State 3
    Read input
    Determine next state
    State
    Read input
    Determine next state
    And so on...
    But, I am quite new to programming Labview state machines, and can't figure out how to even start when the sequence of states is random instead of fixed!!! I can do 1,2,3,4, like the vending machine VI example, but,  not 1,3,2,2,2,5,2,1 etc. based on external input.  Is there some simple example case I can study?  I can't believe I am inventing this for the first time.
    "select the state to run" 
    But, HOW do I do this???????   This is exactly the question I am asking...how is this done?  Please see the attached 3-state system....how do I hook this up????  I am totally lost here...can you help me understand how to wire this thing??  In this simpe RED/GREEN/BLUE case, my input is just the number a user would input on the front panel....  Apparently, there are two files necessary... a vi and .ctl???  What  is .ctl?
    Thanks,
    Dave
    Attachments:
    forum nov 12 red green blue.vi ‏7 KB
    forum nov 12 red green blue.ctl ‏5 KB

  • How can I create arrays through the same recursive process?

    Hello again!
    I want to create some arrays with names like array1, array2, array3 etc
    through the same for loop.
    Do you know how this can be done? Thanks!
    for (int i = 0; i < 32; i++) {
    byte[] array???=new byte[400];
    }

    I want to create some arrays with names like array1,
    array2, array3 etc
    through the same for loop.
    Do you know how this can be done? Thanks!
    for (int i = 0; i < 32; i++) {
    byte[] array???=new byte[400]; You cannot create new names during runtime (array1, array2 are names).
    You can create a map that associates Strings with byte arrays though:Map<String, byte[]>  map= new HashMap<String, byte[]>();
    for (int i= 0; i < 32; i++)
       map.put("array"+i, new byte[400]);
    // get array associated with array26:
    int j= 26;
    byte[] oneOfTheArrays= map.get("array"+j);kind regards,
    Jos

  • How do I create Arrays for objects?

    I want to create an array of type Cards. Is this the right way of doing it?
    Card decker[];
    decker = new Card[5];
         I always get the error DeckofCards: java:47: missing return statement whenever I compile this.

    Look at line 47 of DeckOfCards.java and see what you've done wrong. The example you posted isn't the problem.
    %

  • How do i create more space on my laptop for a new operating system?

    I would like to install snow leoPARD ON MY OLDER LAPTOP IN ORDER TO clean it out and give it to somebody else but there is not enough room at the moment. How do I create some more room?

    Restart the computer with the C or Option key held down, use the Disk Utility to erase the internal drive, install Snow Leopard onto it, and include the disk. Click here for other steps involved.
    (122003)

  • Create array varible in TestStand 4.0

    Hi  gurus,
           I have a doubt that how can we create Array of string in TestStand 4.0 using C#.NET environment.
    I used following method, but failed to create array:
    objPropertyObj.SetValStringByOffset(10,PropertyOpt​ions.PropOption_InsertIfMissing,"SRU"); // exception here....
    The other following method creates array with empty size:
    objPropertyObj.NewSubProperty("SUBSTITUTE.SRU", PropertyValueTypes.PropValType_String, true, "Arrayw",10 );
    Please let me know how to set the length of the array at second method.
    Thank you,
    regards
    RKK

    You should post to the TS board.
    Try to take over the world!

  • Dynamically create arrays

    I need to create arrays dynamically based on user input. I did try using ArrayList. For example if user enters 4 I did the following:
    ArrayList names=new ArrayList();
    for( i=0;i<4;i++)
       String str="array" + i;
       names.add(str);
    }The ArrayList will contain 4 names.......... but how do I create arrays with those names?
    String t = (String) names.get(i);
    String[] t = new String[10];I tried this code but it creates an array named t instead of whats stored in the ArrayList.
    Please help.........what should I do?

    Please help.........what should I do?You can use an associate data structure such as a HashMap. It stores pairs of values - key and item. The access on key is very fast and it will provide the corresponding item. In your case the key can be the array "name" in the form of a String, and the item can be the associated array.

  • How do I create a 1d array that takes a single calculation and insert the result into the first row and then the next calculation the next time the loop passes that point and puts the results in thsecond row and so on until the loop is exited.

    The attached file is work inprogress, with some dummy data sp that I can test it out without having to connect to equipment.
    The second tab is the one that I am having the problem with. the output array from the replace element appears to be starting at the index position of 1 rather than 0 but that is ok it is still show that the new data is placed in incrementing element locations. However the main array that I am trying to build that is suppose to take each new calculation and place it in the next index(row) does not ap
    pear to be working or at least I am not getting any indication on the inidcator.
    Basically what I am attempting to do is is gather some pulses from adevice for a minute, place the results for a calculation, so that it displays then do the same again the next minute, but put these result in the next row and so on until the specifiied time has expired and the loop exits. I need to have all results displayed and keep building the array(display until, the end of the test)Eventually I will have to include a min max section that displays the min and max values calculated, but that should be easy with the min max function.Actually I thought this should have been easy but, I gues I can not see the forest through the trees. Can any one help to slear this up for me.
    Attachments:
    regulation_tester_7_loops.vi ‏244 KB

    I didn't really have time to dig in and understand your program in depth,
    but I have a few tips for you that might things a bit easier:
    - You use local variables excessively which really complicates things. Try
    not to use them and it will make your life easier.
    - If you flowchart the design (very similar to a dataflow diagram, keep in
    mind!) you want to gather data, calculate a value from that data, store the
    calculation in an array, and loop while the time is in a certain range. So
    theres really not much need for a sequence as long as you get rid of the
    local variables (sequences also complicate things)
    - You loop again if timepassed+1 is still less than some constant. Rather
    than messing with locals it seems so much easier to use a shiftregister (if
    absolutely necessary) or in this case base it upon the number of iterations
    of the loop. In this case it looks like "time passed" is the same thing as
    the number of loop iterations, but I didn't check closely. There's an i
    terminal in your whileloop to read for the number of iterations.
    - After having simplified your design by eliminating unnecessary sequence
    and local variables, you should be able to draw out the labview diagram.
    Don't try to use the "insert into array" vis since theres no need. Each
    iteration of your loop calculates a number which goes into the next position
    of the array right? Pass your result outside the loop, and enable indexing
    on the terminal so Labview automatically generates the array for you. If
    your calculation is a function of previous data, then use a shift register
    to keep previous values around.
    I wish you luck. Post again if you have any questions. Without a more
    detailed understanding of your task at hand it's kind of hard to post actual
    code suggestions for you.
    -joey
    "nelsons" wrote in message
    news:[email protected]...
    > how do I create a 1d array that takes a single calculation and insert
    > the result into the first row and then the next calculation the next
    > time the loop passes that point and puts the results in thsecond row
    > and so on until the loop is exited.
    >
    > The attached file is work inprogress, with some dummy data sp that I
    > can test it out without having to connect to equipment.
    > The second tab is the one that I am having the problem with. the
    > output array from the replace element appears to be starting at the
    > index position of 1 rather than 0 but that is ok it is still show that
    > the new data is placed in incrementing element locations. However the
    > main array that I am trying to build that is suppose to take each new
    > calculation and place it in the next index(row) does not appear to be
    > working or at least I am not getting any indication on the inidcator.
    >
    > Basically what I am attempting to do is is gather some pulses from
    > adevice for a minute, place the results for a calculation, so that it
    > displays then do the same again the next minute, but put these result
    > in the next row and so on until the specifiied time has expired and
    > the loop exits. I need to have all results displayed and keep building
    > the array(display until, the end of the test)Eventually I will have to
    > include a min max section that displays the min and max values
    > calculated, but that should be easy with the min max function.Actually
    > I thought this should have been easy but, I gues I can not see the
    > forest through the trees. Can any one help to slear this up for me.

  • How can I create a variable size array?

    How can I create a variable size array?

    ok then how can i create a new vector object?If you don't know that, you need to go back to your text book and study some more. Or read the tutorial on the basics of Java: http://java.sun.com/docs/books/tutorial/java/index.html
    After reading that you can move on to: http://java.sun.com/docs/books/tutorial/collections/index.html
    Anyway, the answer to your question is, of course:
    Vector v = new Vector();(But you should probably use ArrayList instead of Vector.)

  • How do you create a 2-d array%3F

    How do you create and write a 2-d array??  I have two operations in the same WHILE loop.  Each execution of the loop should generate a new  pair of values.  
    However, the BUILD ARRAY function only outputs a 1-d array to the WRITE TO SPREADSHEET FILE.vi. 
    Perhaps, more broadly, how does one put data into a 2-d array as it is collected?  I think I am building two arrays simultaneously below, but, what I really want is to build a single 2-d array.  Is this how you would do it?  It looks clumsy connecting sequential BUILD ARRAY's together.  Is this creating a 2-d array that I can search later by index and return the paired data? 
    Lastly, why does my front panel indicator only show data in the first column??  How do I make it display the data as it is collected across the rows?
    Thanks,
    Dave
    Solved!
    Go to Solution.
    Attachments:
    forum dec 12_2012 build 2d array.vi ‏13 KB

    dav2010 wrote:
    Sorry, very simple minded here...how do pairs go as a 1-d array?  I thought that (x,y) data must be a 2-d array...a column of "x's" and a column of "y's"?  Wouldn't a 1-d array just be all x's?  I admit I'm pretty new to understanding arrays.
    " build your 1D array from both scalars"  -->  how do you do this??  I cannot find a "convert to scalar" on the pallette.
    Also, here is the vi saved down to 2009, I think.
    Dave
    Here's a simpler way, just write out your X and Y as a 1D array each iteration. The Write will append your data as a column of X's and a column of Y's:
    or generate all your values and then write once:
    (fix the broken wire).
    “A child of five could understand this. Send someone to fetch a child of five.”
    ― Groucho Marx

  • How do I create my own favorite template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to templates, which take more memory. I have a large slideshow, and need all the space I can get

    First, how do I create my own favorite theme template for DVD slideshows? I used to be able to select this from pulldown menu, but cannot now do so. I am directed straight to already existing themes, which take more memory. I have a large slideshow, and need all the space I can get. I just want to use a picture as my DVD cover, and then insert a slideshow. Also, when I try to burn my 8.5gb double sided slideshow, all that burns is the music. It is a large slideshow, a memorial on the life of my now deceased brother. This means a lot to me and to my family, and I am having so much trouble trying to burn it. I have gone into Project View and selected appropriately. The bar shows I have room to burn this DVD, but it does not burn.  I have burned so many DVDs in the past, but this one just will not burn. I am so confused at this point. I will say this is the first 8.5gb I have attempted to create and burn. My specs list a 7.7gb or 4.7gb as operable....but there are no 7.7gb dvds. I had to purchase 8.5gb. Help? What am I doing wrong? I have spent so much time on this, and just cannot figure it out.

    Final Cut is a separate, higher end video editor.  The pro version of iMovie.
    Give iPhoto a look at for creating the slideshow.  It's easy to assemble the photos in an album in iPhoto, put them in the order you want and then make a slideshow of them.  You can select from various themes and transitions between slides and add music from your iTunes library.
    When you have the slidshow as you want use the Export button at the bottom of the iPhoto window and export with Size = Medium or Large.
    Save the resulting Quicktime movie file in your Movies folder.
    Next, open iDVD, choose your theme and drag the QT movie file into the menu window being careful to avoid any drop zones.
    Then follow this workflow to help assure the best qualty video DVD:
    Once you have the project as you want it save it as a disk image via the File ➙ Save as Disk Image  menu option. This will separate the encoding process from the burn process. 
    To check the encoding mount the disk image, launch DVD Player and play it.  If it plays OK with DVD Player the encoding is good.
    Then burn to disk with Disk Utility or Toast at the slowest speed available (2x-4x) to assure the best burn quality.  Always use top quality media:  Verbatim, Maxell or Taiyo Yuden DVD-R are the most recommended in these forums.
    The reason I suggest iPhoto is that I find it much easier to use than iMovie (except for the older iMovie 6 HD version).  Personal preferences showing here.

  • How do you create an array without using a shell on the FP?

    I want to be able to read the status of front panel controls (value, control box selection, etc.) and save it to a file, as a "configuration" file -- then be able to load it and have all the controls set to the same states as were saved in the file. I was thinking an array would be a way to do this, as I have done that in VB. (Saving it as a text file, then reading lines back into the array when the file is read and point the control(s) values/states to the corresponding array element.
    So how do I create an array of X dimensions without using a shell on the front panel? Or can someone suggest a better way to accomplish what I am after? (Datalogging doesn't allow for saving the status by a filename, so I
    do not want to go that route.)

    Thanks so much m3nth! This definitely looks like what I was wanting... just not really knowing how to get there.
    I'm not sure I follow all the icons. Is that an array (top left with 0 constant) in the top example? And if so, that gets back to part of my original question of how to create an array without using a shell on the FP. Do I follow your diagram correctly?
    If I seem a tad green... well I am.
    I hope you understand the LabVIEW environment and icons are still very new to me.
    Also, I had a response from an NI app. engineer about this problem. He sent me a couple of VI's that he threw together approaching this by using Keys. (I still think you are pointing to the best solution.) I assume he wouldn't mind m
    e posting his reply and the VI's for the sake of a good, thorough, Roundtable discussion. So here are his comments with VI's attached:
    "I was implementing this exact functionality this morning for an application I'm working on. I only have five controls I want to save, but they are all of different data types. I simply wrote a key for each control, and read back that key on initialization. I simply passed in property node values to the save VI at the end, and passed the values out to property nodes at
    the beginning. I've attached my initialize and save VI's for you to view. If you have so many controls that this would not be feasible, you may want to look into clustering the controls and saving the cluster as a datalog file.
    Attachments:
    Initialize_Settings.vi ‏55 KB
    Save_Settings.vi ‏52 KB

  • How do I create a new frame using Flash CS5 on a Mac so I can add more pictures to my website?

    I have what I hope is a fairly straight forward question that I hope you can answer if you write code with a Mac or are at least familiar with the process on a Mac?  The person I have been working with to create my photography website uses a PC.  Here is the problem.  I am trying to use my Mac in order to create frames so that I can add 5 more images to a portfolio that presently has 15 images.  The code is in an index.fla file.  If I want to create a new frame in the index.fla, let's say LOAD CODE 381 and want to use the same text that is already present in LOAD CODE 380 but with a few edits, I have no trouble going to the Action-Movie Clip and finding LOAD CODE 380 in the left hand column.  The problem is, on a Mac, how do I create frame LOAD CODE 381 and then how do I copy and paste the text from LOAD CODE 380 into LOAD CODE 381?  It looks like on a PC one can open LOAD CODE 380 in the Action-Movie Clip, highlight the text then right click on the red rectangular box in the timeline.  By doing so (on a PC) one sees a drop down menu that gives the option to "copy key frame".  What is the equivalent of the "copy key frame" on a Mac?  I can see where on the Mac you can go to Edit >copy.  Is this the equivalent of "copy key frame" on a PC?  If so, once I "copy" the text how do I create the new LOAD CODE 381 so that I can paste the text into the new frame?
    I WOULD BE EXTREMELY GRATEFUL TO ANYONE WITH THE ANSWER TO THIS QUESTION!  THANK YOU!!!!!

    Sorry not to be more clear.  It is a name assigned to one of the 
    frames by the person who originally designed the website and is shown 
    in the list of about 150 action frames that were created in this 
    particular fla document.  This "list" comes up in the left hand column 
    of the Action-Frame box. When I click on Load Code 380 which is half 
    way down the column of frames, the following text comes up on the 
    large screen to the right of the column of 130 frames.
    IMAGE.gotoAndPlay("start");
    loadVariables("data/series01/15title.txt", "_root.IMAGE.TITLE");
    loadVariables("data/series01/15price.txt", "_root.IMAGE.PRICE");
    loadMovie("data/series01/about.swf", "_root.IMAGE.ABOUT");
    IMAGE.mc_pic.attachMovie("pic","pic",1,)
    IMAGE.mc_picTHUMB.attachMovie("pic","pic",1,)
    This text is what I am trying to transfer to copy then paste into a 
    new frame after which time I want to slightly edit the text.  I am not 
    a programer so I apologize if I am not using all of the correct 
    terminology.
    Thank you again,  Jon

  • How do I create more than one ipod account on one computer

    I have an eighty gig ipod and just recently bought a Clip and want to sync both to my music is it possible. If not how do I create two accounts on the same computer?

    If you are adding a second iPod for your own use you don't need two accounts. Just connect your new iPod (by Clip I presume you mean an iPod shuffle) to your computer and follow the on screen instructions to register and name it and you can choose whatever setting you like to sync it. iTunes will recognise each device that you add and they will have their own settings.
    There are several different ways to use two or more iPods with one computer, have a look at this help page for suggestions and choose the method that suits you best: How to use multiple iPods with one computer

Maybe you are looking for

  • Crystal Reports - Report Creation Error

    Hello! I've been working with ACT! Premium 2010 and Crystal Reports for about 2 weeks now. Friday we decided we needed to create a new database to work with, we had to scrap all old reports and start new. We created the main database on Friday and po

  • ORA-00600 Error when using DBCA

    Hello, I installed Oracle 9.2.0.1 on Linux Redhat 7.3. The installation says everything went fine. I attempted to create a database by using the dbca just to make sure things were really working. However, I receive the following error: ORA-00600 inte

  • Can I use my US account in the UK?

    That was pretty much it. Are there any issues with using my US Adobe account in the UK? I will be there for about 2 1/2 months.

  • Oracle 8.1.7 on WinME

    Hi! I just installed Oracle 8.1.7 on WinME. Everything is working out fine. However, while I wanna login to SQL*Plus, it shows the error as below: ora-12560: TNS : protocol interface error Does anyone can help me out? I am not sure it's my problem or

  • Dynamic Order by with user defined Where clause...

    Hello! I have a block based on a table, with no order by set and no where clause. The block is queryable so users can filter the data to be retrieved. Each of the columns on the form have a button above which requeries the block, applying the order b