How to output last 4 arrays from a For Loop?

Hi People,
I am almost at the end of my tether. I really hope someone could please help me.
Any input would be welcome. VI attached.
VI explanation:
I initialize an array.
The random number generator simulates my camera input.
Depending on which iteration it is, the data is added into one of four output arrays.
'x-y*floor(x/y)' gives a remainder value of 0, 1, 2 or 3.
'Case Selector' just adds 1 to 'x-y*floor(x/y)' to get case 1, 2, 3 or 4.
Shots 1, 5, 9 etc are added to Array 1 (Case 1).
Shots 2, 6, 10 etc are added to Array 2 (Case 2).
Shots 3, 7, 11 etc are added to Array 3 (Case 3).
Shots 4, 8, 12 etc are added to Array 4 (Case 4).
Averaged Output displays the averaged value i.e. the total value divided by the number of shots saved in that array ('Set (IQ+1)').
My problems are:
1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
Where should I place my file save diagram disable so that it does this?
Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)
Putting it outside the main For Loop with auto-indexing off gives me only the last set of data. (I need the output for 4 Arrays, not just the last run)
Putting it inside the main For Loop (as shown) gives me the same number of files as number of iterations. (Again not feasible due to large number of files that will be generated and slow camera capture)
For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
I am using Labview 2010.
Thanks so much,
Jaslyn
Solved!
Go to Solution.
Attachments:
Help Understanding Arrays and file paths (10).vi ‏26 KB

Thanks so much Lennard!!
Hi JKSH,
I've been busy trying to complete the dang code, but for completeness so that other users can learn too, I shall answer your queries. Thanks for looking in.
First, what do you mean by "add"? Your code in your case strcuture sums your input values, so your array size doesn't change. However, you also said "Putting it outside the main For Loop with auto-indexing on gives me one file with all previous data. (This is not feasible as my number of shots should number in the thousands)" -- it sounds like you are expecting an array with thousands of elements. So, what should "Output Array N" look like?
Ans: Output Array N should be a 4x4 array of the summation of all the numbers generated during every 4th iteration.
i.e. if random number 1=1, random number 2=2, etc, And 'No of iterations' is 12,
Output Array 1 should be 1+5+9:
15 15 15 15
15 15 15 15
15 15 15 15
15 15 15 15
(Note: Most of your arrays are 4x4, but in Case #2 you created 128x128. I prersume this is a typo?)
Ans: Kind of, I'm using a 4x4 array of randomly generated numbers as an example but my actual data will be the 128x128 pixel output of a camera. And during actual experimentation, 'No of Iterations' will number in the thousands.
Second, why do you add your "simulated camera input" to the "Initialized Array"? You can add it direcly to the previous output inside your case structure.
Ans: See answer to question 3
Third, have a look at shift registers: http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm. Use them instead of Feedback Nodes to make your code tidier.
Ans: I did try.. But I can't seem to add shift registers to the case structure, only the for loops outside. Are you sure it can be done..?
jaslyn wrote:
1) I would like to output only the last 4 sets of data from the Averaged Output 1, 2, 3 and 4 to 4 different files (i.e. save as .csv what is displayed onscreen in indicators 'Averaged Output 1', 2, 3 and 4 at the end of all iterations.
Where should I place my file save diagram disable so that it does this?
For the sake of fast camera capture, I would like these 4 files to only output once all the image captures are complete.
You will need to call "Write to Text File.vi" 4 times to write 4 files. So, you should finish your loop, then call this VI 4 times.
Ans: How do I get it to extract the data from each of the 4 cases in my case structure?
jaslyn wrote:
2) Would preferably like to name the file once and for the programme to append '(1)', '(2)', '(3)' and '(4)' to filename of the appropriate 'Averaged Output' Arrays but file path controls are another big headache for me.
You can create strings first, then convert them into paths: http://zone.ni.com/reference/en-XX/help/371361G-01/glang/string_to_path/
Thanks
jaslyn wrote:
3) P.s. is initializing one array enough to avoid using Memory Manager? Or should I initialize 4 arrays?
I'm not sure what you're asking; can you please clarify what you mean by "avoid using Memory Manager"? But anyway, you've actually initialized FIVE arrays: 1 outside the loop, and 1 inside each case.
I've read that to avoid fluctuations in memory usage, it is a good idea to initialize arrays to their expected size before the start of data collection. That was just what I was trying to do.

Similar Messages

  • Building an array from a for loop.

    Hi all
    I have a vi which reads from a file and manipulates the data using for loop. I am taking each element and multiplying it with a constant and converting it to I32. I would like to build back to a new array with the new values. I have attached the vi and a sample data file to read from.
    Please suggest if there are any better ways to do this.
    Thank you. 
    Solved!
    Go to Solution.
    Attachments:
    file_read.vi ‏11 KB
    file_read.txt ‏1 KB

    You can multiply the array with the constant and use the array instead of multiplying it with each element.
    The best solution is the one you find it by yourself

  • Code for how to read an integer array from the command prompt...

    hello,
    Could anyone give me the code for how to read an integer array from the command prompt...its very urgent!..

    If you are using a recent version of Java (5 or later) you can use Scanner:
    http://java.sun.com/javase/6/docs/api/java/util/Scanner.html
    That page has some example code on it, too.

  • How can I turn off Keychain from asking for my password EVERY time I check for mail?

    how can I turn off Keychain from asking for my password EVERY time I check for mail?
    This is really driving me nuts.....
    Thanks

    Choose Apple menu > System Preferences, click Security & Privacy, and then click General. 
    Open the General pane of Security & Privacy preferences
    2.     Select “Require password...NEVER after sleep or screen saver begins.”  You can adjust the amount of delay before a password is required in the pop-up menu.
    From what I am aware, you cannot turn off the keychain.
    I hope this helps.
    This is also a link that might help http://macs.about.com/od/systempreferences/ss/Mac-Security-Using-The-Mac-Securit y-Preference-Pane_2.htm

  • TS3999 How do you Change the sent from email for iCal invitations on my iPad. It uses the iCloud email but I want it to use my work email.

    How do you Change the sent from email for iCal invitations on my iPad. It uses the iCloud email but I want it to use my work email.
    It keeps sending from my bosses ICloud account, we are all synced at work but I want all my invitations to come from me, not my bosses iCloud account!
    Need to know how to do it on the iPad!!

    Hi garretktowne,
    Welcome to the Support Communities!
    The article below may be able to help you with this issue.
    Click on the link to see more details and screenshots. 
    Apple ID: Changing your Apple ID
    http://support.apple.com/kb/HT5621
    Cheers,
    - Judy

  • How do you choose which photos from Aperture for Apple TV screen saver?

    How do you choose which photos from Aperture for Apple TV screen saver?

    How do you choose which photos from Aperture for Apple TV screen saver?

  • How to get the elements out of a for loop simultaneously during the loop execution

    Hi, 
    I am student. I would like to know how to get the counter values outside the For loop parallely while the loop runs rather that getting the finally value outside the For loop. Looking forward for answers.
    Thanks,
    Athira
    Solved!
    Go to Solution.

    You could use a notifier (since it is a single value) or a reference (with a property node) to a control that gets the value elsewhere in another VI.
    If it is within the same VI, you could use a property node (right click > create > property node > value) from the control within the same VI located outside the loop.
    If you promiss NOT to abuse the use of Local Variables, you could use that to only write from ONE location within the For Loop to a control outside the loop, similar to the property node mentionned earlier.  (Of course, I will be struct by lightening for mentionning that and scolded by other LabVIEW coders for having a change of heart on the use of Locals....  Shivers are already crawling up my spine).
    You could use a queue, but that might be an overkill, unless:  the count is generated faster than it is being read elsewhere...
    As crossrulz mentionned, can you describe what you will be doing with the count?  Because synchronizing data (fresh / stale / etc) is very important within LabVIEW as it executes based on dataflow rather than a sequential order.
    Hope this helps. 
    EDIT: 
    You have not fully provided the answer.  We figured that much of your code from your description, but what is reading the value of the count?  Is it in a separate loop?  If not, it may only deal with the first value, which is likely 0.  The proper advice depends on how you process the received data (count).

  • Transposing data in an array using a For Loop

    I am trying to transpose some data in an array using a  for loop starting from the size of the array then decrement down to 0. Can someone please help if you have an example?
    Solved!
    Go to Solution.

    I feel as if reverse 1D array may help
    Edit: misunderstood what your second post meant.
    CLA, LabVIEW Versions 2010-2013

  • Truncating an array within a for loop

    I'm currently working with a program that builds an array of 3000*N real numbers, where N is a control that I specify. I want to pass this array into a for loop that runs N times, each time splitting the first 3000 numbers of the array. So, in other words I want the for loop to execute enough times such that the initial array will be completely divided into groups of 3000 when I'm finished. Later I'll be finding the maximum value of all of these subarrays and taking the average of those. What I tried first is to pass the array into the for loop, then truncate it at index = 3000, but the problem is that I can't hard code the loop to do this N times. Any advice or other methods you'd recommend for doing this?
    Thanks.
    Message Edited by Robtn on 03-05-2010 03:17 PM

    Mark--I don't think I can use that approach. Let me be more specific on what the problem is:
    Our "big program" is a giant while loop that constantly reads in voltage values from a DAQ assistant.
    It has two modes, the first of which I'm having a lot of trouble with. This mode uses a for loop (N = 3000) nested within the giant while loop.
    When the for loop activates, the DAQ assistant takes reads 300 samples for every iteration and takes the maximum of those 300 values. It then builds an array composed of all the maxima. After the for loop has executed 3000 times, a case structure activates, which then finds the maximum of the array of maxima.
    I want this (N=3000) for loop to execute an arbitrary number of times, a number that I will specify. Each of those times it should generate a completely seperate array of maxima. So, if I want the for loop to run 5 times, I want 5 different arrays.
    My approach for doing this was to change N=3000 to say N = 15000, then split up the resulting array 5 times. So, I need an entirely separate for loop that reads in this array of 15000 maxima on its own and splits it 5 ways. I think what you're suggesting is to use a for loop outside of the N=3000 loop, which is a good idea in theory, but experience has shown that this will not generate 5 separate arrays. It will actually concatenate each array into one, hence the problem we currently have.
    Yik--I won't have access to Labview over the weekend. Is it possible to take a screenshot and post it, or maybe a short description?
    Thank you for the responses.

  • How to speed up my code inside the for loops,

    how to speed up my code inside the for loops using c# WinForm.

    Hi  John,
    Please take a look at the reply from Wyck in the following thread.
    How to speed up for loop?
    His answer is very comprehensive.   Thanks.
    Best regards,
    kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to read flushed cluster array from input queue?

    Hi! I'm new to LabView. Can someone please help me?
    I want to use a subvi to read a queue which I created in another vi. The created queue holds an array of clusters that I want to unbundle in a for loop in the reading vi. But the output of the flush queue function is a string array (since the subvi has no info on what sort of queue is being input).
    I can't connect the unbundle function to a string input; can I use the type cast function to force the flush output to be a cluster? Or is there a better way to do this?
    And if so, what is the string constant I need to attach to the "type" input in the type cast function?
    And also, I'm told that the cluster is kind of like a "struct"; so is there a way to n
    ame it so that other vi's know what it is(i.e. type cast)?
    jen

    I did look at the help examples, but I couldn't find one that was sending the queue from one vi to another(well, not any that I could understand), and that was really my problem.
    I did get the thing to work when it was all in one vi.
    You bring up an interesting point about "dequeue" and "flush". Perhaps I am mistaken, but my reasoning for using flush rather than dequeue was the following:
    I am using the queue as a data buffer. I need the queue to hold a few minutes of data. This data is dumped to file upon fault event, i.e. it tells me what was going on right before the fault occurred. I need that queue to dump the data and then immediately turn around and start filling up again. I felt that holding on to the queue reference in the save-to-file routi
    ne (which involves lots of potentially slow hard disk access) might cause the object to lock and hence not be able to save right away. I don't know how LabView does threading, but if I was writing the threading routine, I would lock any object which was being executed upon in a routine to prevent data collision.
    Of course, this begs the question: does LabView lock all objects in a subroutine that is executing? Or just in the part which is unresolved? or does it lock objects at all? Perhaps I should flush the queue outside of the subroutine anyway, so that the subroutine can happily munch on the flushed array while my queue goes back to the business of collecting data?
    Am I way off base in how the threading works?
    Thanks!
    jen

  • How can i get a array from a JSP ?

    Hi all,
    i have a STORED PROCEDURE like this:
    static public void getMyArray(double [] xx) {
    for (int i=0; i<myarr.length;i++){
    myarr=3.145*i;
    xx=myarr;
    return ;
    how can i get the array with XSQL and transform with a XSL ?
    Is this at all possible?
    Thanks for any help.
    Achim

    u r asking how ca u get array from jsp?
    and u r asking xsql ...some stuff i couldnot understand .can u repeat the question properly?
    null

  • How to Output data in vertically from a horizontal format.

    Hello
    I have some difficulties how to display my data in my output table. I am greatful for
    every tips provided. The data in my it_tab is in a horizontal format but I want to
    display this data vertically in my output_tab.
    My it_tab looks like this:
    table: it_tab
    id   date   amnt
    011  2007   1200
    011  2008   1400
    011  2009   6700
    011  2010   3500
    012  2007   ---
    013  2007   3000
    013  2008   1300
    014  2007   1200
    014  2008   ---
    014  2009   9000
    015  2007   2500
    I would like my output_tab should look like this:
    table: t_output
    id  name  date amnt  date1  amnt1 date2  amnt2 date3  amnt3
    011 jx    2007 1200  2008   1400  2009   6700  2010   3500
    012 tx    --
    014 gx    2007 3000  2008   --    2009   9000   --    ---
    015 hx    2007 2500
    t_output already has some data init like id and name.
    This is what I have done but I don't output all the data as I want.
    clear w_output.
    loop at t_output into w_output.
    clear w_itab.
    loop at it_tab into w_itab where id = w_output-id.
    case sy-tabix.
    WHEN '1'.
    w_output-date = w_itab-date.
    w_output-amnt = w_itab-amnt.
    WHEN '2'.
    w_output-date1 = w_itab-date.
    w_output-amnt1 = w_itab-amnt.
    WHEN '3'.
    w_output-date2 = w_itab-date.
    w_output-amnt2 = w_itab-amnt.
    WHEN '4'.
    w_output-date3 = w_itab-date.
    w_output-amnt3 = w_itab-amnt.
    endcase.
    endloop.
    modify t_output from w_output.
    endloop.
    Could some body please tell me how to do this? I think many people in here have come
    across this type of problem before.
    Thank you all for helping out.
    Nadin

    Hi, Nadin!
    I suggest you to create a dynamic internal table with variable number of columns. You can do as follows:
    1. Create basic fieldcatalog for ALV list (or object) output
    CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
              EXPORTING i_structure_name       = 'ZYOUR_BASIC_STRUC'         
              CHANGING  ct_fieldcat = lt_fcat.
    2. Determine max number of columns (that is, max number of dates for each ID)
    SORT it_tab BY id.
    LOOP AT it_tab INTO is_tab.
      AT NEW id.
        ADD 1 TO l_count.
      ENDAT.
      AT END OF id.
        IF l_count > l_max_count.
          l_max_count = l_count.
        ENDIF.
        CLEAR l_count.
      ENDAT.
    ENDLOOP.
    3. Add one entry to fieldcat for each column
    DO l_max_count TIMES.
      l_index_char = sy-index.
      CONCATENATE 'DATE' l_index_char INTO ls_fcat-fieldname.
    *... other fieldcat fields, like texts etc.
      APPEND ls_fcat TO lt_fcat.
      CONCATENATE 'AMNT' l_index_char INTO ls_fcat-fieldname.
    *... other fieldcat fields, like texts etc.
      APPEND ls_fcat TO lt_fcat.
    ENDDO.
    4. Create dynamic table from fieldcat using:
    DATA: dt_outtab TYPE REF TO data. "IMPORTANT: make this declaration global, otherwise error
    FIELD-SYMBOLS: <table> TYPE STANDARD TABLE.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
           EXPORTING it_fieldcatalog = lt_fcat
           IMPORTING ep_table        = dt_outtab.
    ASSIGN dt_outtab->* TO <table>.
    5. Fill this table. To do this you need special techniques since you have a generic table with no static structure. For example:
    FIELD-SYMBOLS: <line>  TYPE ANY,
                   <field> TYPE ANY.
    DATA: l_field_inex TYPE i.
    LOOP AT it_tab INTO is_tab.
      AT NEW id.
        APPEND INITIAL LINE TO <table>.
        READ TABLE <table> INDEX sy-tfill ASSIGNING <line>.
        l_field_index = 3. "you start from 3rd field - #1 is ID, #2 is NAME
      ENDAT.
      ASSIGN COMPONENT l_field_index OF STRUCUTRE <line> TO <field>.
      <field> = is_tab-date.
      ADD 1 TO l_field_index.
      ASSIGN COMPONENT l_field_index OF STRUCUTRE <line> TO <field>.
      <field> = is_tab-amnt.
      ADD 1 TO l_field_index.
    ENDLOOP.
    6. Display your report in alv. You have valid fieldcat and output table which is created dynamically.
    CALL METHOD o_alv->set_table_for_first_display
              CHANGING  it_outtab       = <table>
                        it_fieldcatalog = lt_fcat.
    If you don't use ALV object but rather ALV list, it's similar. Just use corresponding functions for ALV creation and list display.
    Note that this is not a tested code. Just an idea to help you procede.
    <b><REMOVED BY MODERATOR></b>
    HTH.
    Regards,
    Igor
    Message was edited by:
            Alvaro Tejada Galindo

  • How do I copy an array from a website to Excel using Firefox

    Was running Firefox on Windows Vista. I could copy an array from finance.yahoo.com into an Excel spreadsheet by selecting the array with control key down then clicking on edit - copy selected cells, then pasting into an Excel sheet. I only had to tell it the upper left cell and the whole array went in properly
    Now trying to do the same thing on a new machine running Windows 7, but the "copy selected cells" option is not available in the edit menu. Is there a way to copy an array with Firefox and Windows 7? These are big arrays. One cell at a time is out of the question.

    Try this Add-on --> https://addons.mozilla.org/en-US/firefox/addon/dafizilla-table2clipboard/
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''
    Not related to your question, but...
    You may need to update some plug-ins. Check your plug-ins and update as necessary:
    *Plug-in check --> http://www.mozilla.org/en-US/plugincheck/
    *Adobe Shockwave for Director Netscape plug-in: [https://support.mozilla.org/en-US/kb/Using%20the%20Shockwave%20plugin%20with%20Firefox#w_installing-shockwave Installing ('''''or Updating''''') the Shockwave plugin with Firefox]
    *'''''Adobe PDF Plug-In For Firefox and Netscape''''': [https://support.mozilla.org/en-US/kb/Using%20the%20Adobe%20Reader%20plugin%20with%20Firefox#w_installing-and-updating-adobe-reader Installing/Updating Adobe Reader in Firefox]
    *Shockwave Flash (Adobe Flash or Flash): [https://support.mozilla.org/en-US/kb/Managing%20the%20Flash%20plugin#w_updating-flash Updating Flash in Firefox]
    *Next Generation Java Plug-in for Mozilla browsers: [https://support.mozilla.org/en-US/kb/Using%20the%20Java%20plugin%20with%20Firefox#w_installing-or-updating-java Installing or Updating Java in Firefox]

  • How to call a CString array from TestStand

    I have a C++ DLL that uses a CString array, CString myString[ ],  that I need to pass back to TestStand 4.0 for inclusion in my results database.
    In the TestStand module definition the parameter argument Description comes up as a CStriing pointer (CString*) instead of a CStringArray.
    When I put my array of strings into the Value Expression I get an error: Expected String, found Array of Strings.
    I have no trouble passing just a string pointer but that's not working either.
    Can someone help?
    Thanks,
    Steve S

    Hi Steve,
    I don't think that you can pass a CString Array from C++ DLL to TestStand 4.0 directly.
    But you can do it another way: concatenate all Strings by a delimit in your CString Array to build a new String,  then pass it to TestStand. In TestStand you can separate those Strings by the delimit, and rebuild a String Array.
    For example:
    // If this is your CString Array.
    CString myString[] = {"AAA", "BBB", "CCC"};
    // Build a  new String in your C++, and pass it to TestStand.
    char  *myNewString = "AAA~BBB~CCC";
    // Separate myNewString and build an Array in TestStand...
    Hope that can help you!
    Message Edited by My NI on 11-29-2007 11:34 AM
    Regards
    MY

Maybe you are looking for

  • I'm having trouble getting my reset link for my security questions because I no longer have access to the recovery email address

    I'm having trouble resetting my security questions because I no longer have access to the recovery email account that the link gets sent to and I can't make any purchases in the app or iTunes Store until this is fixed because I'm on a new iPad and it

  • N500 - external monitor in dos/bios mode?

    hi all... My primary lcd is broken, works only external monitor in windows mode... Question: how i can access external monitor on dos/bios mode? Now blank screen only. Works under windows driver only. Thanks for all... 3000 n500, graphics mobile chip

  • JTable with multiple colors in one cell

    Hello. I'm looking for a way to display colorized text inside one column of my table. For Example using the String: "^6en^3try" I want ^1 to ^7 to be colorcodes for different colors, so that the substring "en" is displayed in pink and the substring "

  • What is this problem?

    Hi everyone, This lines of code (picture below) have been showed up long time, but I not sure what is it, and even I do verify and repair disk many time, it still exist! DO i have to clean install? By the way, if I click D before ray screen showed up

  • Sales Area Not Maintained

    Gurus, I am trying to create a sales order with reference to a contract. When I am doing the item selection and click on the copy button, it is throwing an error "Sold-to party 100000 not maintained for sales area 2000 20"  where '2000' is the sales