Search 1D array problem

Hey guys,
I'm trying to write (what I imagine) is a simple program to progressively step through a text file in array format, honing in on the maximum value, while comparing values along the way (the attached code will do a better job of explaining).  I am aware that I could simply use a maximum value find to obtain what I am looking for, but this is just a simple exercise to simulate something a bit more difficult I'll be doing down the road, thus I have real reasons for doing this all backwards.
The problem I run across is when using the "search 1D array" command, it only works on certain elements.  For instance, if you load the code I have attached along with the input file, and input a crystal angle of "40" and a an angle offset of "0.01", then run in highlight mode, you'd see that as soon as it got to search for element 40.02, inside the for loop, it wouldn't find element 40.02 in the file and jump the result to "-1" and keep running, but yielding bogus results.  The problem is that 40.02 DOES exist in the array (search for element 198 in the output array to find it).  In addition, if you input 40.02 as the initial starting angle, with the same 0.01 offset, the first run works just fine (finding element 40.02 this time, when not executing in the loop) but bombing out on the search for 40.06, again yielding a value of -1 when the 40.06 actually exists. 
This same type of behavior occurs throughout the array, with certain elements being "un-reachable" via the "Search 1D Array" command when used in the loop, but being reachable when searched for from the initial start, and consistency being shown in the "un-reachable" elements when the code is run over and over.  Again, running the code in highlight mode will clear up any questions about the problem statement, I believe. 
Does anyone have an explanation as to why this is occurring and how to fix it?  I thought maybe it was in the string to number conversion, but that doesn't make sense since it can find the numbers outside the loop, but not in it. 
I am running Labview version 7.0 for the record. 
Thanks!
~Jack
Attachments:
normal 40.34 txt.txt ‏7 KB
file io practice.vi ‏51 KB

I put my and gabi's advice together:
I first had issues in finding any value because my computer takes ',' as the decimal sign instead of '.'
Ton
Message Edited by TonP on 05-29-2007 10:51 PM
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!
Attachments:
file io practice_mod.png ‏18 KB
file io practice_mod.vi ‏26 KB

Similar Messages

  • Search 2D Array

    I need to search for a 2D array, and report the row index. I have serached the array and mathematics functions, but none can handle this extrememly simple task, that is easily done in all other software,(MATLAB, VB, Excel etc).
    I hope I am wrong, and there is a simple VI to handle this task, because I introduced LabVIEW to my colleagues, and I feel embarrased, when they asked me this question, and I can not find a simple VI, but have to start designing a for or while loop for a simple task.

    DFGray wrote:
    It may be faster to reshape the array to a 1D array, do the search (once), then reshape back to 2D (presuming you are using again.  You will need to convert from position in the 1D array to position in the 2D array, but that is a simple operation.
    Here's an old example.
    (To find only the first match, delete the two loop structures. )
    (If there is only one match, you could do a comparison between the array (of any dimension!) and the element to be found, followed by "boolean to 0,1), followed by "array min/max". The index output of the array max is the desired value. )
    DFGray wrote:
    Please add this functionality as a suggestion in the LabVIEW Idea Exchange.  I will vote for it!
    The functionality we need is is a simple polymorphic VI ("Search array" would replace the current "search 1D array") that accepts arrays of any dimensionality and returns the index as an array, one element for each dimension. The start index would accept such an array too. (There might be some problems incrementing to the next element when searching for multiple occurrences, so we might need some helper tools).
    The function would search the elements in the order of the flattened array.
    LabVIEW Champion . Do more with less code and in less time .

  • Search timestamp array for a specific value

    Hello,
    I need some help creating a VI that will allow me to do some data post-processing.  The problem is multifaceted, so help on any aspect will be of great help.  The end goal of the VI will allow the user to select two times, intial and final, and create a plot based on the corresponding data vs. the time selected, and output to a .jpg. 
    1.  How do I find the index of the time array?  Right now, no matter what time value i input, the index is zero.  The time input should only be significant at most to seconds.
    2.  How do i select all the values between the two chosen times?
    3.  Is there a better way to read in my .tdm file?
    4.  Documentation on exporting plots?  I also have Diadem.
    Attached is the VI that im working with.  The post unfortunately does not allow .tdm files.  I can't say that i've gotten very far, so any advice would be much appreciated.
    Alex
    Attachments:
    post-analysis.vi ‏50 KB

    The "Threshold 1D Array" works in a similar manner as the "Search 1D Array" except that it doesn't try to find an exact match. It finds the two array elements between which your search value falls. It then tells you a fractional index that basically tells you where it falls between those two values. So, a value of 2.5 means it falls smack in the middle between the third and fourth elements of the array. A value of 2.1 means it would fall just after the third element, and a value of 2.9 means it would fall just before the fourth element. The one caveat is that the array must be monotonically increasing. The "Interpolate 1D Array" can be used to interpolate a value given the fractional index. In your case it isn't really necessary - I was showing it for demonstration.
    As to your specific question, I'm not sure which array you're talking about. When you run the VI does the "32bit ingerer" indicator give you the correct index based on the timestamp that you're looking for?

  • Search result pages problem

    When I perform a search on a specific category on these forums, I get the first page of the results. But when I go a next page, I don't get a page with results of my search, but  the results of a search on all categories.

    The problem also arises with a single bowser window:
    1) do a search
    the first results page is correct
    2) clicking next or a page number gives results from all categories
    3) going back to the first page with results and clicking the search button (redo the current search) fixes the problems, now next and the page number links work correct.
    I've traced the problem down to this html:
    <a href="search!execute.jspa?q=sbo&dateRange=last90days&rankBy=10001&start=0"
                                 class="jive-current"
                                 >1</a>
    vs
    <a href="search!execute.jspa?q=sbo&objID=f56&dateRange=last90days&forceEmptySearch=true&rankBy=10001&start=0"
                                 class="jive-current"
                                 >1</a>
    The first is the result of a search on the main sbo forum page: SAP Business One SDK
    while the second is a result of a search done from the search form where you can specify which forum to search, which date range, user id, etc. (this is the form that is displayed above every page with results.
    Both resulting pages look 100% identical, but with the first search, the next pages are wrong. (because objID is missing in the links)
    I think this pretty much explains it. Now it's up to somebody else to fix it

  • How to search for array in another array ?

    i want to search for array in another and when i got this array i want to take the next 5 bits  EX: array1 [ 4 8 7] , array2 [ 9 1 4 8 7 6 3 2 ] , output array [ 6 3 2 9 1]
    Thanks  

    I know we should be encouraging others to help them selves, but I had a solution that I think is what the user wants.  Attached is a VI that searches for a subarray in an array, and will return the index it is found at.  It will also return the input array, filtered if a match is found.  This VI just handles the double data type.
    Most of the code comes from an old post by Altenbach that I can't seem to find at the moment, but I saved a copy a while ago.  Props to him for posting it.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Filter Subarray - DBL.vi ‏18 KB

  • A quick Array Problem

    hey all,
    i'm having a dumb array problem, I cannot figure out what I've done wrong !
    I've set up an empty array of JButtons (because that '4' is actually a variable in my code)
    HERE IS THE CODE
    //===========================
    JButton[] buttons = new JButton[4] ;
    for (int g = 0; g < 4; g++)
    Imag[g].setIcon(imageIcons[g]);     
    buttons[g].setEnabled(true);
    System.out.print (buttons[g] + " " + g + "\n");
    //===========================
    My Error is a null pointer exception. And when I take out the:
    buttons[g].setEnabled(true);
    line, I just get the ouput, and it is:
    null 0
    null 1
    null 2
    null 3
    Ok, I know I'm probably making one dumb little mistake, but I have no idea what it is right now, Please Help !! thanks,
    Kngus

    When you want to use an array, you declare it (which you did), construct it (which you did), and initialize it (which the VM did). When you initialize an array of primitives, the primitives get their default value (0 for signed int types, 0.0 for float types, false for boolean, null-character for char) and so do object references (null).
    You are setting up an array of object references. When the VM initializes it, the elements of the array (i.e. the references to the JButtons) are set to null. That's why you're getting the NullPointerException. You need additional code, something along the lines of this:
    for(int j = 0; j < buttons.length(); j++) {
        buttons[j] = new JButton();
    }Now, your buttons array will contain references to JButtons rather than null.
    AG

  • Transposin​g Array Problem

    I need to get the information from a table which has been populated at an earlier point in the program, and convert it to numbers, and then break it up into its individual elements. Both ways of doing this in my attached vi work, but the one method throws three 0's in between columns, when I resize the 2D array to 1D. Any idea why? Is there an easier way to go about this?
    Thanks, Geoff
    Attachments:
    Array Problem.vi ‏26 KB

    Your original table contains 3 extra row which generate 3 rows of zeroes. Your 2D array actually contains 35 elements. the reshape function truncates to 20 elements. After transposing, you throw away nonzero elements while before rehshaping all zeroes are in the tail giving the false apperance of correct behavior.
    The attached modification gives you a button to fix the table size so it works correctly.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ArrayProblemMOD.vi ‏41 KB

  • Search 1D array doesn't works.

    Hi.
    I have a bunch of data. Let say 48000 elements. And from it, I try to search, one element using 'Search 1D array' .
    However it doesn't work as wanted.
    I put an indicator on output of the 'Search 1D array' , but the value always "-1".
    Anybody could help me. Please refer to my VI as reference. The 'Search 1D array' is used under case structure of "Synchronize Pressure and Alpha".
    Thanks.
    Firdaus
    Solved!
    Go to Solution.
    Attachments:
    Acquifinale Updated 8 - Real World - other Different Method.vi ‏154 KB
    Calculation.vi ‏15 KB

    Hi Norbert,
    Please find the attachment below.
    By the way, could you give one example on how to change the array from DAQ into integeter. Because, as from your suggestion, I simply use converter 'To Unsigned Byte Integer'.
    Firdaus
    Attachments:
    Acquifinale Updated 8 - Real World - other Different Method.vi ‏155 KB
    Calculation.vi ‏15 KB

  • How to Search and Array for multiple occurrences of a value

    Hi,
    I am trying to search an array of doubles for a number and report the index location(s) of a number. I.e. -allow for repetition. Search and report all index[i] where the number is contained in the array. For example I have
    double[] myInputArray = new double[5];
    double[] myInputArray = { 1, 2, 3, 3, 5 }I know how to search through the array ONCE and return the first occurrence of a number:
    public double GetIndexOf(double Number) {
        for (int i=0; i<myInputArray.length; i++) {
             if (myInputArray[i] == Number){
                  return(i);
        return(-1);
      }How do I expand this code to report multiple index[i] locations if the number reoccurs in the array like the number 3 does in my example array above?

    The way the Java libraries do this type of operation (String.indexOf(), etc) is to specify the starting index along with what you want to find.
    Changing your example slightly (notice how I fixed your naming and more importantly, your return type):
    public int indexOf(double num) {
       return indexOf(num, 0);
    public int indexOf(double num, int fromIndex) {
        for (int i=fromIndex; i<myInputArray.length; i++) {
             if (myInputArray[i] == num){
                  return(i);
        return(-1);
    //usage to get all indices:
    for ( int index = -1; (index = indexOf(num, index+1)) != -1; ) {
       System.out.println(index);
    }Note that due to how floating point numbers work, you may find doing this on doubles (or any other operation that uses == with double arguments) to give you unexpected results.

  • Is there a way to search an array?

    Post Author: Andrew Reedick
    CA Forum: Formula
    CR has the 'x in &#91;y&#93;' operator which will tell you if x in is in array y.  However that returns a boolean. 
    Is there anything that will search an array and return the index if the item is found?  Or do I have to write my own formula to do so?  (This is using CR syntax.)
    On a side note, does CR syntax support multi-dimension arrays?

    Post Author: Andrew Reedick
    CA Forum: Formula
    CR has the 'x in &#91;y&#93;' operator which will tell you if x in is in array y.  However that returns a boolean. 
    Is there anything that will search an array and return the index if the item is found?  Or do I have to write my own formula to do so?  (This is using CR syntax.)
    On a side note, does CR syntax support multi-dimension arrays?

  • Associative Array problem in Oracle Procedure

    Hi,
    I've searched through the internet and this forum and haven't been able to resolve a problem using associative array values within an IN clause. Everything I've read states that I can't use the associative array directly in the SQL statement. I have to convert it to a table and then I can use it. Unfortunately, I'm receiving an "ORA-21700: object does not exist or is marked for delete" error when trying to access the table I've populated from the array. Please note that I have verified the table is actually being populated during the loop. I'm catching the error when referencing it in the SELECT statement.
    I've declared the following in the ARCHIVE package specification:
    TYPE RSType IS REF CURSOR;
    TYPE integer_aat IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    TYPE integer_table IS TABLE OF INTEGER;
    The procedure is as follows:
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array
    v_term = Keyword entered
    rs = Result Set
    tbl_cat ARCHIVE.integer_table := ARCHIVE.integer_table();
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT * FROM TABLE(tbl_cat))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;
    Any help would be greatly appreciated and thanks in advance,
    Matt

    Thank you for the quick response. I looked at the example you suggested and made the following changes. Now I'm receiving an "Invalid datatype" error on the "SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer))" statement. I must be missing something simple and I just can't put my finger on it.
    PROCEDURE SEL_SEARCH_RESULTS (v_term IN VARCHAR2,
    v_categories IN ARCHIVE.integer_aat,
    rs OUT RSType)
    AS
    /* PURPOSE: Return Search Results for the Category and Keyword Provided
    VARIABLES:
    v_categories = Document Categories array entered
    v_term = Keyword entered
    rs = Result Set
    TYPE tbl_integer IS TABLE OF INTEGER;
    tbl_cat tbl_integer;
    BEGIN
    FOR i IN 1 .. v_categories.COUNT
    LOOP
    tbl_cat.EXTEND(1);
    tbl_cat(i) := v_categories(i);
    END LOOP;
    OPEN rs FOR
    SELECT A.ID,
    B.CATEGORY,
    A.FILENAME,
    A.DISPLAY_NAME,
    A.COMMENTS
    FROM TBL_ARCHIVE_DOCUMENTS A,
    TBL_ARCHIVE_DOC_CAT B,
    TBL_ARCHIVE_DOC_KEYWORDS C
    WHERE A.ID = B.ID
    AND A.ID = C.ID
    AND B.CATEGORY IN (SELECT column_value FROM TABLE(CAST(tbl_cat AS tbl_integer)))
    AND C.KEYWORD = v_term
    ORDER BY A.ID;
    END SEL_SEARCH_RESULTS;

  • Insert element into array problem

    Hi,
    I have problem about how to insert value into an array. here is one section, could anyone help me to insert input value into array and delete the first value in the array. Gap means to fill in code
    void Ins(String name)
    // Insert name or increment its multiplicity.
    // If the bag is full remove the oldest entry.
    int i; // Running index on BagName
    int target; // if target < n then name.equals(BagName[target]);
    // else target == n
    Date EntryDate; // Current date and time
    // Get current date and time
    EntryDate = new Date();
    BagDate[n] = EntryDate.toString();
    Mult[n] = n+1;
    BagName[n] = name;
    n++;
    // Search bag for name
    // Gap 2
    // Assertion: target < n => name.equals(BagName[target])
    // else target == n
    // Update Mult if target < n
    // Gap 3
    // Make room for and insert name if target not found
    } // Ins(String name)
    Message was edited by:
    sibojava
    Message was edited by:
    sibojava

    Do you have several accounts?
    See this thread, it's the same question:
    http://forum.java.sun.com/thread.jspa?threadID=5143232
    Kaj

  • External SCSI Disk Array problem

    I am using a quad MacPro, 3 GB RAM, 10.4.11, ATTO UL5D SCSI card and an external U320 SCSI disc array. In the last few days I could not copy bigger then 3-6 GB files to the external SCSI storage, from the internal drives or from the an external firewire drive, because the system stalls and I have to restart the system using the power on button.
    Any idea what can be the probelm? I checked the SCSI cables, termination, reseated the SCSI card, etcm but the problem remained.

    First thing I would do is make sure your data and volumes are fine and run Disk Warrior.
    Second, check that you have the latest ATTO drivers and firmware.
    Are you using Apple Disk Utility, SoftRAID, or something else?
    Can you rule out problem being with FW disconnected, or other PCIe cards?
    Last, unrelated, up the memory to 4 x 1GB or more. What Apple recommended for Final Cut, symmetrical memory, or quad-channel,
    http://www.barefeats.com/quad09.html
    Mac Pro Discussion:
    http://discussions.apple.com/category.jspa?categoryID=194
    ATTO UL5D
    http://www.google.com/search?q=ATTOUL5D+MacPro

  • Search Service Application problems after upgrading from Foundation to Enterprise edition of SharePoint 2013

    Hi all. I have been searching for days for a solution to a problem I am having with SP2013 Enterprise edition.
    We recently upgraded from SP2013 Foundation to SP2013 Enterprise. After the upgrade, the search services are no longer working and we are receiving many application log entries indicating the following:
    Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (ea2019ef-bb9e-4efe-85ee-5d2307406f31).
    Reason: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
    Technical Support Details:
    System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
       at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
       at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)
    as well as:
    Application Server Administration job failed for service instance Microsoft.Office.Server.Search.Administration.SearchServiceInstance (ea2019ef-bb9e-4efe-85ee-5d2307406f31).
    Reason: The object you are trying to create already exists. Try again using a different name.  
    Technical Support Details:
    System.Runtime.InteropServices.COMException (0x80040D02): The object you are trying to create already exists. Try again using a different name.  
       at Microsoft.Office.Server.Search.Administration.SearchServiceInstance.Synchronize()
       at Microsoft.Office.Server.Administration.ApplicationServerJob.ProvisionLocalSharedServiceInstances(Boolean isAdministrationServiceJob)
    I have tried to remove the search service application and recreate it, and even though the SharePoint Central Administration states that it was created successfully, I am still getting the same errors in the log. If I go to the Search Service Application
    Search Administration page, the "System Status" shows the following message:
    The search service is not able to connect to the machine that hosts the administration component. Verify that the administration component '0359af35-0982-4ede-8838-b1d390e915bf' in search application 'Search Service Application' is in a good state and
    try again
    Additionally, under the "Search Application Topology" section, it states "Unable to retrieve topology component health states. This may be because the admin component is not up and running" which I assume is normal if the admin is not
    running.
    Does anyone know how I can resolve this problem? 
    Thanks!

    Hi Joaquin,
    According to your description, the error occurred when you re-created the Search Service Application.
    Based on the error message, I recommend to verify the things below:
       1. Check if the association between the Search Service Application proxy and the web application is configured.
    Please go to Central Administration > Application Management > Configured service application associations > Click Default to see if the Search Service application is checked.
       2. Change the app pool for the Search Service Application to SharePoint Web Services Default in the properties of the Search Service Application.
    Please go to Central Administration > Application Management > Manage service applications > Highlight the Search Service Application > Click Properties in the ribbon > Change
    the two app pool to SharePoint Web Services Default: App Pool For Search Admin Web Service and Application Pool for Search Query and Site Settings Web Service.
        3. Run PS command to check if the search admin timer job is enabled: Get-SPTimerJob
    job-application-server-admin-service | fl. If it is not enabled, use PS command to enabled it and then reset Internet Information Services: Enable-SPTimerJob job-application-server-admin-service.
    Best regards.
    Thanks
    Victoria Xia
    TechNet Community Support

  • MS Office Report Express VI and Array Problem

    Hello all,
    I have a strange issue with the MS Office Report VI that's included with the Report Generation Toolkit. I created an Excel template which I linked using the "Custom template for Excel" preference and applied all the named ranges. However, two of the named ranges that I am inputting are 1D Arrays of doubles. Now the problem:
    When I input the arrays to their specific name range (it's only 6 values), instead of inputting just the array values into the cells, it inputs like this:
    0    Value
    1    Value
    2    Value
    6    Value
    It pushes the "Value" to the column next to the name range because of the 0-6.
    It does this with both arrays so it screws up all the formulas. Any one know how to remove the 0-6 and just input the values?
    Thanks all 
    Solved!
    Go to Solution.

    Greetings, I wrote a program that generates an array of data and stores a data table, just as a chart, just starting to program, I hope that my program can be useful
    Atom
    Certified LabVIEW Associate Developer
    Attachments:
    write_excel.vi ‏60 KB

Maybe you are looking for