Problem searching array

I have an array in a column that I extracted from a data file. I want
to search the array for particular values and return the index which
is easily implemented by the search 1d array subvi. However, when I
input the values to search, it returns a -1 for some values and others
it finds fine where I know all the values exist. To be more precise,
my array is about 80 values between -2 and 2 in steps of 0.05. When I
search for -2, -1.5, -1, etc., I get the correct index. When I search
for other numbers like -1.8, -1.7, -1.85, etc., I get a return value
of -1. It is really strange and I am not sure of the problem. Anyone
have any ideas? Does it have anything to do with the precision or how
I read the spreadsheet file to extract the column?
T
hanks
Heather

Thanks for all your help. I ended up converting both the search array
and the search element to strings with 2 decimal point precision and
it works fine.
You guys are the best.
Heather
[email protected] (H) wrote in message news:<[email protected]>...
> I have an array in a column that I extracted from a data file. I want
> to search the array for particular values and return the index which
> is easily implemented by the search 1d array subvi. However, when I
> input the values to search, it returns a -1 for some values and others
> it finds fine where I know all the values exist. To be more precise,
> my array is about 80 values between -2 and 2 in steps of 0.05. When I
> search for -2, -1.5, -1, etc., I get the correct index. When I
search
> for other numbers like -1.8, -1.7, -1.85, etc., I get a return value
> of -1. It is really strange and I am not sure of the problem. Anyone
> have any ideas? Does it have anything to do with the precision or how
> I read the spreadsheet file to extract the column?
>
> Thanks
> Heather

Similar Messages

  • Search array

    Hello all,
    I have a problem regarding to search array.
    It seems like he is unable to find certain elements in the 1D array I deliver. 
    Because it outputs -1.
    I attached my vi + the file
    Koen
    UnCertified LabVIEW Student
    Mistakes are for learning, that's why suggestions are always welcome!
    Solved!
    Go to Solution.
    Attachments:
    Problem.vi ‏17 KB
    test2.txt ‏135 KB

    You can't accurately do an equals comparison with floating point numbers.  It is just a limitation of floating points in gereral (all computer languages have this issue).  What you should do instead is check to see if a value is in a certain range to account for this limitation.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Problem searching on a table

    I'm having problem searching data from a table.
    I'm able to search every single row but when it gets to the last one, it keeps going to the last result.
    I want it to search everytime I press the button and once it gets to the last result I want a message to popup saying that there is no more results. I also want to add the ScrollPane to change along with the search.
    here is the code.
    searchText = new String(search.getText());
    int rows = mainTable.getRowCount();
    int columns = mainTable.getColumnCount();
    Object value = null;
    lastindex= -1;
    for(int i=0; i<rows; i++)
    for(int j=0; j<columns; j++)
    value = mainTable.getValueAt(i,j);
    //System.out.println(i + " " + value);
    if (value == null ? searchText == null :
    value.toString().equalsIgnoreCase(searchText) && i > lastindex
    mainTable.setRowSelectionInterval(i, i);
    mainTable.setColumnSelectionInterval(j, j);
    lastindex = i;
    return;
    }//if()
    }//for
    }//for
    JOptionPane.showMessageDialog(null, "No More Players ",
    "Search",
    JOptionPane.INFORMATION_MESSAGE);

    Sure,
    Can u send a test mail to this user id
    [email protected]...will look into ur issue.
    Thanks

  • Search Array with multiple values

    Hello,
    I've been helped with the prototype below by blemmo (thanks).
    It allows me to search my array using one property == a
    value.
    Now, I'd like to use it to:
    if ((prop1 == val1) &&(prop2 == val2) &&
    (prop3 == val3) {
    // search array for all values in array with the values of
    val1, val2 and val3
    Also, a way to search if one of the prop and val's are blank,
    ie...
    ((prop1 == val1) &&(prop2 == val2) && (prop3
    == val3)
    where prop2 and val2 are "undefined"
    so the search will only search for the prop and val that are
    not "undefined"
    make since? Don't know where to start.
    help and thanks in advance.

    it is an array like this.. but with more properties... also,
    is it better to use XML to load large arrays or is it ok to use
    actionscript in the file.
    which is faster to load? say if I had an array of 150
    elements?
    myArray = [{myname:"bob", county:"skagit", city:"Sedro
    Woolley", id:1,
    pic:"1.jpg",pic1:"2.jpg",pic2:"3.jpg",pic3:"4.jpg"},
    {myname:"bob", county:"skagit", city:"Sedro Woolley", id:1,
    pic:"1.jpg",pic1:"2.jpg",pic2:"3.jpg",pic3:"4.jpg"

  • Having problems searching for music

    I just recently encountered a problem searching for music on the Itunes store. I searched under song title, and it didn't bring up any results. Then I searched for the same music under artist, and the music came up. What's weird here is that the music was always there, but it's not showing up when I try to search under song title. Can someone tell me what's going on here?

    If the song is a part of "Compilation", you cannot find it using Artist or Genres. But you can find it searching through Albums or Compilations. Try that, maybe that's you problem.

  • Searching arrays using ascii

    I am trying to solve a book problem. I created an array with letters and numbers and I'm supposed to figure out how to count the number of letters in the array. I tried the following code:
    public class ArrayBasics1
      public static void main(String[] args)
         char[] myChar = {'1','2','3','a','b','c','d','e','f'};
         int count = 0, uncount = 0, x = 0;
         for(x = 0; x < myChar.length; ++x)
           //myChar[x] = (char)x; Doesn't work
           if(myChar[x] > 96 && myChar[x] < 123)
              count += 1;
           else
                   uncount += 1;
           System.out.println("The number of letters in myChar is " + count);
           System.out.println("The number of characters in myChar which are not letters is " + uncount);
    }  I think I'm searching the subscripts rather than the content of the array. Any help would be appreciated.

    I just ran your code and it gave the output:
    The number of letters in myChar is 6
    The number of characters in myChar which are not letters is 3
    This looks good to me - what were you expecting? I'm not sure what you were trying to do with "//myChar[x] = (char)x; Doesn't work", but you don't need that line.
    One improvement you might want to make is to use the Character.isLetter() method which also includes upper case letters. e.g. replace
    if(myChar[x] > 96 && myChar[x] < 123)with
    if (Character.isLetter(myChar[x]))Good Luck

  • Search Array of String for exact match words

    I need to create a search feature.
    There will be a textfield where the user will input a word or words.
    Then I need to check if the are any reference in the array of names.
    namesArray ["ocean in the sky", "cean on sky", "cean is white"];
    keywordsArray ["cean", "sky"];
    matchCounter = 0;
    If I input the word "cean" I dont want in my results "ocean in the sky", only "cean is sky".
    I have the following code:
    for (var j:int = 0; j < namesArray.length; ++j)
         var tempStr:String = namesArray[j];
         for (var k:int = 0; k < keywordsArray.length; ++k)
              if (tempStr.indexOf(arrayKeywords[k]) != -1)
                  matchCounter++;
         if(lengthKeywords == matchCounter)
              trace("yeahhh... there's a match!!");
         matchCounter = 0;
    Is there a better way? How can I do this?

    There are few things but the main problem is that "new RegExp()" needs double escapes ("\\")
                var namesArray:Array = ["ocean in the sky", "cean on sky", "cean is white"];
                var keywordsArray:Array = ["cean", "sky"];
                for (var j:int = 0; j < namesArray.length; j++){
                    var matchCounter:uint = 0;
                    var tempStr:String = namesArray[j];
                    for (var k:int = 0; k < keywordsArray.length; k++){     
                        var regExp:RegExp = new RegExp("(\\s+|^)" + keywordsArray[k] + "(\\s+|$)"); 
                        if (tempStr.search(regExp) > -1){
                            matchCounter++;
                    if(keywordsArray.length == matchCounter){
                        trace("\"" + namesArray[j] + "\" matched all the keywords");
    Traces:
    "cean on sky" matched all the keywords

  • Compare and search array

    Hallo
    I have to compare a input data and the ideal data. so far i have understood how to do comparision but the problem create when ideal array have same element with different respective value , similarly input dat are appears to be also same but while doing search in final output array  in 3 column looks different than as it should be.
    hope you understand my problem
    thanking you
    BR
    kalu
    Solved!
    Go to Solution.
    Attachments:
    array%20(modified)[1].vi ‏17 KB

    Hi Kalu,
    Check the attached VI. Let me know if it helps.
    Regards,
    Nitz
    (Give Kudos to Good Answers, Mark it as a Solution if your Problem is Solved)
    Attachments:
    array (modified)[1].vi ‏17 KB

  • Re: Sorting a searched array

    If allowed you could write several Compartors and use Collections.sort()
    If not then you will have to write several of your own sort methods. Whatever logic you would have placed in the Comparators you would place in your sort methods. If it is the logic you are having problems with:
    Sort by X
    If 1.X and 2.X are the same then sort by Y
    If 1.Y and 2.Y are the same then sort by Z
    etc.

    Hello,
    Thanks for helping! I'm getting the logic you wrote. But when I sort by arrays, then I will need to run a for loop in order to shift the elements right? I'm not understanding how to set the condition for the 'for' loop. For example, if I have a total of 5 records in the inventory and only 3 of them satisfy the search..then I can run a loop as follows:
    public void SortProduct()
    for(int i=0;i<3;i++)
        if(inventory.getProductName==inventory[i+1].getProductName)
    sortModel();
    But the number of searched elements may differ from time to time, right? Like when user enters another product, and only two records satisfy the criteria, then the loop condition should become for(int i=0;i<2;i++). I'm not getting how to dynamically change the value so the loop runs for any number of elements depending on the search results at that time.
    Also, is my sort method right? I'm not too good at it.
    Edited by: Beginner_Troubles on Apr 17, 2008 7:59 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • CRM IC Webclient - Massive Performance Problems Searching in Agent Inbox

    Hi Forum,
    can somebody help me. We have massive Search Performance problems in Interaction Center Webclient in Agent Inbox. When agents searching, for example for open emails, the time to get a result takes approx. 2-3 minutes.
    Thats absolute inadmissible and endangered the running business.
    The queury reading the eMails from the workitem tables is very very slow.
    Could somebody help me with ideas to solve this big performance problem. Have somebody the same problems?
    Thank you very much in advance for any information.
    We use Interaction Center Webclient on CRM Release 5.0
    Thorsten

    Another aspect you could check is the following:
    Analysis performed didn't show anything strange nor any high consumers
    of the response time. The processing time occurs, since IC-Web on CRM 5
    is a bit demanding for CPU power.
    The only thing that could improve the performance a bit is the
    <b>buffering of org structure</b>, which is currently switched off for
    SALES and SERVICE scenarios as per table T77OMATTSC.
    The report <b>HRBCI_ATTRIBUTES_BUFFER_UPDATE</b> is running regulary
    however no scenario is being placed in the buffer to speed up
    org structure read. Please check this and provide feedback.
    How to use this report, can be found back in the Reports own documentation and also in SAP HELP.
    cheers
    Davy

  • Problem in array output, pls help!

    i made an array:
    public class Estudyante
         String studentNo;
         String studentName;
         String address;
         String phone;
         String email;
         public void displayDetails()
              System.out.println(studentNo);
              System.out.println(studentName);
              System.out.println(address);
              System.out.println(phone);
              System.out.println(email);
    public class StudentFinder
         //define the variables of the class
         Estudyante estObjects[];
         //initialize the variables
         public StudentFinder()
              //creating an array of 3 estudyantes
              estObjects = new Estudyante[3];
              //creating objects of all the three elements in an array
              for(int ctr = 0; ctr !=estObjects.length;ctr++)
                   estObjects[ctr] = new Estudyante();
              //assigning test values
              //estudyante 1 details
              estObjects[0].studentNo = "0001";
              estObjects[0].studentName = "Rez";
              estObjects[0].address = "Pasig";
              estObjects[0].phone = "111-1111";
              estObjects[0].email = "[email protected]";
              //estudyante 2 details
              estObjects[1].studentNo = "0002";
              estObjects[1].studentName = "Reza";
              estObjects[1].address = "Manila";
              estObjects[1].phone = "222-2222";
              estObjects[1].email = "[email protected]";
              //estudyante 3 details
              estObjects[2].studentNo = "0003";
              estObjects[2].studentName = "Reza Ric";
              estObjects[2].address = "Malate";
              estObjects[2].phone = "333-3333";
              estObjects[2].email = "[email protected]";
         //declare the method of the class
         public void displayFinder()
              //add the code for displaying estudyante details
              for (int ctr = 0;ctr != estObjects.length;ctr++)
                   estObjects[ctr].displayDetails();
                   //the displayDetails() method is present in the Estudyante class
         //code the main() method
         public static void main(String args[])
              StudentFinder finderObject;
              finderObject = new StudentFinder();
              finderObject.displayFinder();
    problem:
    when i run this in command prompt, it displays all the 3 sets of details
    question:
    how will i display the set of details i want and not all of them?
    eg: i only want the details of studentNo = "0001"
    so in command prompt i execute
    java StudentFinder 0001
    how will i be able to get the details for studentNo = "0001" only and how will i display "No such student" if the studentNo asked for is not in any of the details.

    Hi KikiMon,
    In your displayFinder() method you'll have to take an argument, specifying which Student to display. Like this:
    public void displayFinder(String target)
    for (int ctr = 0;ctr != estObjects.length;ctr++)
    if(estObjects[ctr].studentNo.equals(target)) {
    estObjects[ctr].displayDetails();
    An in your main you'll have to forward a commandline argument like this:
    public static void main(String args[])
    StudentFinder finderObject;
    finderObject = new StudentFinder();
    finderObject.displayFinder(args[0]);
    Later,
    Klaus

  • Problem in Array of JCheckBox

    I am facing a problem with the array of JCheckBox. Without array it works but when I use array it gives NullPointerException. No compile time error. I am using Null Layout. But I need to use the array. How can I solve this?
    Here is the code.
    JCheckBox jCheckBox_Questions[] = new JCheckBox[3];
    JCheckBox box = new JCheckBox();
    Dimension d[] = new Dimension[3] ;
    String strQuestions[] = {"No Child ?","Jaundice ?","Migraine ?"};
    int j=20,k=150;
    // This works
    box.setText(strQuestions[0]);
    add(box);
    d[1]= box.getPreferredSize();
    box.setBounds(j,k,d[1].width,d[1].height);
    k=k+20;
    //When I add the follwing fragment it gives NullPointerException
    jCheckBox_Questions[0]. setText(strQuestions[1]);// in this line
    add(jCheckBox_Questions[0]);
    d[2]= jCheckBox_Questions[0].getPreferredSize();
    jCheckBox_Questions[0].setBounds(j,k,d[2].width,d[2].height);

    Hi,
    classic error: in fact the code
       JCheckBox jCheckBox_Questions[] = new JCheckBox[3]; doesn't instantiate the checkboxes, it's only allocating 3 memory pointers (inited to null), ready to receive the futures instances of checkboxes. So you should have typed:
       JCheckBox jCheckBox_Questions[] = new JCheckBox[3];
       // Here we create the 3 objects
       for (int i=0;i<3;i++) jCheckBox_Questions[ i ] = new JCheckBox();
       //...Hope this will help,
    Regards.

  • A basic question/problem with array element as undefined

    Hello everybody,
    thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
    Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
    Albertus
    Antenna
    Antique
    Arial
    Arimo
    Avant
    Barber1
    Barber2
    Barber3
    Barber4
    Birch
    Blackoak ...etc
    Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
    The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
    undefinedAlbertus
    undefinedAntenna
    undefinedAntique
    undefinedArial ...etc.
    I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
    Here is my code:
    #target illustrator
    var doc = app.documents.add();
    //open file
    var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
    var openFile = myFile.open("r");
    //check if open
    if(openFile == true){
        $.writeln("The file has loaded")}
    else {$.writeln("The file did not load, check the name or the path");}
    //load the file content into a variable
    var content = myFile.read();
    myFile.close();
    var ch;
    var x = 0;
    var fontList = [];
    for (var i = 0; i < content.length; i++) {
        ch = content.charAt (i);
            if((ch) !== (String.fromCharCode(10))) {
                fontList[x] += ch;
            else {
                x ++;
    for ( i = 0; i < fontList.length; i++) {
       $.writeln(fontList[i]);
    doc.close (SaveOptions.DONOTSAVECHANGES);
    Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank you

    CarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
    This has helped me do something similar to what your doing.
    Thanks again CarlosCanto
    // script.name = fontList.jsx;
    // script.description = creates a document and makes a list of all fonts seen by Illustrator;
    // script.requirements = none; // runs on CS4 and newer;
    // script.parent = CarlosCanto // 02/17/2013;
    // script.elegant = false;
    #target illustrator
    var edgeSpacing = 10;
    var columnSpacing = 195;
    var docPreset = new DocumentPreset;
    docPreset.width = 800;
    docPreset.height = 600;
    var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
    var x = edgeSpacing;
    var yyy = (idoc.height - edgeSpacing);
    var fontCount = textFonts.length;
    var col = 1;
    var ABcount = 1;
    for(var i=0; i<fontCount; i++) {
        sFontName = textFonts[i].name;
        var itext = idoc.textFrames.add();
        itext.textRange.characterAttributes.size = 12;
        itext.contents = sFontName;
        //$.writeln(yyy);
        itext.top = yyy;
        itext.left = x;
        itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
        // check wether the text frame will go off the bottom edge of the document
        if( (yyy-=(itext.height)) <= 20 ) {
            yyy = (idoc.height - edgeSpacing);
            x += columnSpacing;
            col++;
            if (col>4) {
                var ab = idoc.artboards[ABcount-1].artboardRect;
                var abtop = ab[1];
                var ableft = ab[0];
                var abright = ab[2];
                var abbottom = ab[3];
                var ntop = abtop;
                var nleft = abright+edgeSpacing;
                var nbottom = abbottom;
                var nright = abright-ableft+nleft;
                var abRect = [nleft, ntop, nright, nbottom];
                var newAb = idoc.artboards.add(abRect);
                x = nleft+edgeSpacing;
                ABcount++;
                col=1;
        //else yyy-=(itext.height);

  • HP Proliant ML350G4 server - problem with array

    Hi, I have HP Proliant ML350 G4 server. The problem is that I can not configure the array for SCSI hard drives. When I run the Array Configuration Utility from the SmartStart CD, I get the message: "ACU did not detect any supported controllers in your system." How do I solve this problem?

    Hi:
    You may also want to post your question on the HP Business Support Forum -- ML Servers section.
    http://h30499.www3.hp.com/t5/ProLiant-Servers-ML-DL-SL/bd-p/itrc-264#.U48mculOW9I

  • EBay web page problem - search for item last time was ok now not ok ! I copied and pasted into IE it worked ok but not on Firefox !! why ???

    I have lots of tabs of eBay search pages which I update every day and from last night (26th Sep) and even now 27th they still have the same problem that the search does not continue but goes to a eBay home page !
    I tried going back in history but the same thing came up again and again.
    I copied a link from my history in Firfox and pasted it into IE which came up Ok - I copied that into Chrome and that was Ok as well !
    I copied it back to Firefox and Still Came Up with the Same wrong page !!! Why ???
    Please Please can you help ?

    When you have a problem with one particular site, a good "first thing to try" is clearing your Firefox cache and deleting your saved cookies for the site.
    (1) Bypass Firefox's Cache
    Use Ctrl+Shift+r to reload the page fresh from the server.
    Alternately, you also can clear Firefox's cache completely using:
    orange Firefox button (or Tools menu) > Options > Advanced
    On the Network mini-tab > Cached Web Content : "Clear Now"
    If you have a large hard drive, this might take a few minutes.
    (2) Remove the site's cookies (save any pending work first). While viewing a page on the site, either:
    * right-click and choose View Page Info > Security > "View Cookies"
    * Alt+t (open the classic Tools menu) > Page Info > Security > "View Cookies"
    In the dialog that opens, you can remove your eBay cookies individually.
    Then try reloading the page. Does that help?

Maybe you are looking for