How to compare 3 values in array

Hi all
This is my first post so please be tolerant
I need to find "bad values" in array, it will be easier to explain it using example so:
I have array like this: 0 0 0 0 0 0 0 0 5 0 0 0 0  <- so "5" is the bad value, my method is to check two of nearby values so x(i-1) = 0, x(i)=5 x(i+1)=0, and if checked value is more than 25% bigger or smaller it should be replaced by average of neighborhood.
next example: 0 1 2 3 4 9 6 7 8 <- bad value is 9, and result of my filter should be (4+6)/2 = 5
I've done it using formula node (not 20% and not average, but the point is the same) and it's working but now I want to do it without C and I had lots of problems with memory cause the size of array is 10000.
I attached vi and signal thah you can check that it's working fine
Thanks
Mike
Solved!
Go to Solution.
Attachments:
vi+signal.zip ‏62 KB

MeeHow wrote:
next example: 0 1 2 3 4 9 6 7 8 <- bad value is 9, and result of my filter should be (4+6)/2 = 5
Shouldn't e.g. the value 4 be outside too, because the average of 3 and 9 (=5.5) is more that 25% different to 4?
Here is a quick draft comparing three versions (LabVIEW 8.2):
Your formula node version
the same algorithm in G
Something along the lines you are proposing here.
As you can see, the new idea is not quite satisfactory. It needs more thought. Still, these drafts should give you some ideas how to do it. Modify as needed.
Also your data is similar to a square wave and has these large step functions where the value changes dramatically. These should probably be ignored. Maybe you should look at the first derivative and replace parts where a large positive slope is immediately followed by a negative slope of similar size, for example.
You should also look at absolute steps instead of percentages. If you use percentages and the value is zero, everything is outside, because even 5000% of zero is still zero, right?
LabVIEW Champion . Do more with less code and in less time .
Attachments:
filter testMOD.vi ‏41 KB

Similar Messages

  • How to pass value in array to another procedure?

    Hello.
    I have created application by Developer form9i.
    And I have some problem about passing value in array to another procedure.
    My code is :
    PROCEDURE p_add_array (col_no in number,
    col_val in varchar2) IS     
    type xrecord is record(col number,vcol varchar2(1000));
    xrec xrecord;
    type varraytype is varying array(42) of xrecord;     
    xvartab varraytype := varraytype();
    alert number;
    BEGIN
    set_application_property(cursor_style,'busy');
    xrec.col := col_no;
    xrec.vcol := col_val;
    xvartab.extend(1);
    xvartab(col) := xrec;
    EXCEPTION
    when others then
    set_application_property(cursor_style,'default');
    alert := f_show_alert('!Error ORA-'||
    to_char(DBMS_ERROR_CODE)||' '||
    substr(DBMS_ERROR_TEXT,1,240),
    'al_stop');          
    END;
    And I want to have
    PROCEDURE p_print_arrey is
    BEGIN
    END;
    So how to bring value of xvartab( ) in p_add_array to use in p_print_array?
    Anybody please help me solve this ploblem.

    Hi,
    Instead of declaring the array locally within the procedure (i.e. p_add_array), define it in the package specification (i.e. Under Program Units).
    -- Shailender Mehta --

  • How to compare values in table control

    Hi Experts,
    How to compare two values of a field in table control. Like the frist row of feld1 with the second row of field1.
    because when ever two values are same i need to display error message that we are entring duplicate entry.
    i have been tring for a very log time but not getting any solution for this.
    Thanks and Regards,
    Ashwin.

    you need to write in code for this..
    A possible solution is given below..
    Suppose your internal table fields are col1 and col2.
    in the loop .....endloop of yout internal table in your PAI..there will be  following(if your table control is made using wizard. otherwise you might have to add it..
    loop at itab.
    chain.
    field col1.
    field col2.
    "some module
    endchain.
    endloop.
    now make changes as shown to the above code..
    loop at itab.
    chain.
    field wa-col1.
    field wa-col2.
    module table_modify on chain-request.
    endchain.
    now in your program add module table modify.
    module table_modify input.
    read table itab with key col1(which shud be unique) = wa-col1 transporting no-fields.
    if sy-subrc = 0. " there exists another record with the same value
    message e001(your message class).
    endif.
    endmodule.
    i guess that shud work. get back if it dosnt.
    regards
    Suzie

  • How to compare the same array?

    Hello,
    The question not how to compare arrays.
    I have a method that gives results of an array type int.
    for(......){
    int [] arrayFunc(int [] input)
    return arrayOut;
    }I want to compare those arrayOut arrays. I need to find a way to save the first output and then compare it with the newest output. Where do I have to put the temp array to temporary save the array? What should happen if I want to keep track of the results and get comparisons of first, second, third output?
    Thanks

    Still not 100% sure but I try and help. What you need to do is have two references. After you have generated a result compare it to the last result. After the comparison you need to assign the current result to the last result and then go around the loop again to generate a new current result. Below is some code that uses plain ints but I hope it illustrates what I am trying to explain.
    import java.util.Scanner;
    class ComparingNumbers {
      public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int current;
        System.out.print("Number: ");
        int last = scanner.nextInt();
        scanner.nextLine();
        for(int index = 0; index < 10; index++) {
          System.out.print("Number: ");
          current = scanner.nextInt();
          scanner.nextLine();
          System.out.println("Difference is " + Math.abs(current - last));
          last = current;
    }

  • How to compare values in resultset

    i am having problem in comparing result set values. Actually my store proc returns me the following resultset:
    Month | Year | Deductible | Troop | TDC | ReasonCode
    ------------|-----------|-----------------|------------|-------------|--------------------------
    January | 2008 | $100.0 | $0.0 | $0.0 | 1
    ------------|-----------|-----------------|------------|--------------|--------------------------
    January | 2008 | $0.0 | $10.0 | $0.0 | 1
    ------------|-----------|---------------- |-------------|-------------|-------------------------
    January | 2008 | $0.0 | $0.0 | $20.0 | 1
    ------------|-----------|-----------------|-------------|-------------|-------------------------
    March | 2008 | $150.0 | $0.0 | $0.0 | 2
    ------------|-----------|-----------------|-------------|-------------|--------------------------
    March | 2008 | $0.0 | $15.0 | $0.0 | 2
    ------------|-----------|-----------------|-------------|-------------|-------------------------
    March | 2008 | $0.0 | $0.0 | $30.0 | 2
    i will compare month and year fields. i.e if year is same the compare month and if month is same (e.g. January) the first three row of the above table will be clubbed in one row i.e.
    Month | Year | Deductible | Troop | TDC | ReasonCode
    ------------|-----------|-----------------|------------|--------------|--------------------------
    January | 2008 | $100.0 | $10.0 | $20.0 | 1
    how can i do it in my result set?

    Learn SQL
    "Select Month, Year, SUM(Deductible), SUM(Troop), SUM(TDC), ReasonCode from table Group By Month, Year, ReasonCode"Otherwise, loop through the resultset and compare the fields you want to compare using .equals() and sum the values yourself (of course).

  • How to compare value before and after

    hi,
    one of the queried Values ​​is the number of defective frames.Here, this value is compared with a previously sampled value
    If now (after 10 s) this value is bigger than previous one ,then It saves new value otherwise loop will be continue.If again after (10s) the new value is bigger than  previous  new value then again saves this new point.how can i comapre value before and after?thanks.
    Tadhika

    Do you know what a shift register is? It preserves a value from one loop iteration to the next. Please read the LabVIEW Help on shift registers. There's is also a simple example that ships with LabVIEW that will give you the basic idea (Help -> Find Examples).
    You can also use a Feedback Node in lieu of a shift register. Same concept, different implementation.

  • How to compare value of two Combo Box

    I've two Combo Box(cbFirst & cbSecond). I want to compare the value that has been selected by the user and based on the result, output is displayed. In both Combo Box I've provided the value.
    Here is my code:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
        trace(a);   
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    cbSecond.addEventListener(Event.CHANGE, Second);
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);
    The trace statement inside the functions are working fine and the correct value of a & b is printed. But the comparison in the if statement doesn't seem to work. Could you please help me out.

    there's a typo.  fix it or remove it:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
    trace(a);
       compareF();
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    compareF()
    cbSecond.addEventListener(Event.CHANGE, Second);
    function compareF(){
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);

  • How to compare values in collection.

    Hi,
    I am using oracle 11g XE, I am doing a validation using bulk collect collection.
    DECLARE
    TYPE TEM IS TABLE OF VARCHAR2(1000);
    EM TEM;
    P_MAIL VARCHAR2(1000);
    BEGIN
    P_MAIL := UPPER('[email protected]');
    SELECT EMAIL BULK COLLECT INTO EM FROM
    SELECT UPPER(EMAIL_ID)   AS  EMAIL FROM SONARA_CONSULTANT_DETAILS
    UNION
    SELECT EMAIL_ID_2 AS  EMAIL FROM SONARA_CONSULTANT_DETAILS
    ) WHERE EMAIL IS NOT NULL;
      FOR I IN EM.FIRST..EM.LAST LOOP  
        IF  P_MAIL = EM(I) THEN    // Here i am comparing the mail id with collection but it always goes to INVALID
        DBMS_OUTPUT.PUT_LINE('VALID');       
         ELSE
         DBMS_OUTPUT.PUT_LINE('INVALID');       
        END IF;
      END LOOP;
    END;
    } Please suggest me how to do the comparison
    Thanks
    Sudhir

    It seems that you don't compare everywhere in uppercase, so for me this is rather a letter case problem in your string addresses. The following works for me
    DECLARE
        TYPE TEM IS TABLE OF VARCHAR2(1000);
        EM TEM;
        P_EMAIL VARCHAR2(1000) := '[email protected]';
    BEGIN
        WITH SONARA_CONSULTANT_DETAILS AS
            SELECT '[email protected]' AS emailAddr FROM DUAL UNION
            SELECT '[email protected]' AS emailAddr FROM DUAL UNION
            SELECT '[email protected]'  AS emailAddr FROM DUAL UNION
            SELECT '[email protected]' AS emailAddr FROM DUAL UNION
            SELECT '[email protected]' AS emailAddr FROM DUAL UNION
            SELECT '[email protected]' AS emailAddr FROM DUAL UNION
            SELECT '[email protected]' AS emailAddr FROM DUAL UNION
            SELECT '[email protected]' AS emailAddr FROM DUAL
        SELECT emailAddr BULK COLLECT INTO EM
        FROM SONARA_CONSULTANT_DETAILS;
        FOR indx IN EM.FIRST .. EM.LAST
        LOOP
            IF UPPER(P_EMAIL) = UPPER(EM(indx))
            THEN
                DBMS_OUTPUT.PUT_LINE('VALID');
            ELSE
                DBMS_OUTPUT.PUT_LINE('INVALID');
            END IF;
        END LOOP;
    END;
    /Which gives me the following result
    INVALID
    INVALID
    INVALID
    INVALID
    INVALID
    INVALID
    INVALID
    VALID
    PL/SQL procedure successfully completed.
    SQL> Regards,
    Dariyoosh

  • How to change value of array element using property node

    hello all : )
    im using an array of combo-box. the size of array is not fixed.
    i want to use the strings[ ] property of combo-box to enter selection texts but since i have placed it inside the array im unable to use this property.
    i used 'arrayelem' reference property and connected property node to it but didnt got strings [ ] in the selection.
    so is there any way i can use the strings [ ] property
    Solved!
    Go to Solution.

    the picture what I posted is a snippet. It is a png file which also contains a vi:
    http://www.ni.com/tutorial/9330/en/
    I have found this post. I am just reading it:
    http://forums.ni.com/t5/LabVIEW/combobox-in-array-why-does-it-work-this-way/m-p/2146916/highlight/tr...
    It might help...
    hmm, it is more complicated as I thought )
    edit: just to be CLEAR: so you want to create a new selection LIST for each of the array elements (comboboxes)) OR you just want to set all the comboboxes to a particular value which is ALREADY in the combobox list??

  • How to compare value in input field to value in database?

    Hi all. I need to clear up if the value in the input field (e.g. input_field) is equal to at least one record in the field (e.g. name) in database table (e.g. customers), or not. The code should be like this:
    IF...
      message001.  "(there's such a record in database)
    ELSEIF...
      message002.  "(there's no such record in database)
    ENDIF.
    thanks all.

    Hi,
    I think u r asking about validating the selction screen and displaying a mess if that input is not in the DB right?
    AT SELECTION-SCREEN ON s_matnr.
    *Validate material no details
      PERFORM validate_matno.
    FORM validate_matno.
      SELECT SINGLE matnr INTO v_matnr
             FROM mara
             WHERE matnr IN s_matnr.
      IF sy-subrc NE 0.
        MESSAGE i128.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.
    Make sure that u are validating against the header table.
    say eg if u wnat t validate matnr in marc, then do as below.
    SELECT-OPTIONS: s_matnr FOR  marc-matnr.                  "Material No
    AT SELECTION-SCREEN ON s_matnr.
    *Validate material no details
      PERFORM validate_matno.
    FORM validate_matno.
    DATA: v_matnr LIEK mara-matnr.
      SELECT SINGLE matnr INTO v_matnr
             FROM <b>mara</b>
             WHERE matnr IN s_matnr.
      IF sy-subrc NE 0.
        MESSAGE i128.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.
    Dont select from marc.
    Hope this is clear.

  • How to compare records in singe internal table

    Hi Folks,
    iam having 3 records in my first itab( T_FINAL) with fields
    material no,  descrip ,  mat type and  group.
    and 16 records in second itab(T_MVKE ) with fields
    mat no ,  distri.chanel  and division
    now I want to fetch the records from T_MVKE  by comparing the records in
    T_FINAL .my requirement is to check the given mat no. in sales org.2000,2100.  if yes then i have to consider 2000 only, if it is in only 2100 then consider 2100 only . is it is in 2000 only then consider 2100 only
    my code is
    LOOP AT T_FINAL.
        READ TABLE T_MVKE WITH KEY MATNR = T_FINAL-MATNR.
       IF SY-SUBRC = 0.
       ON CHANGE OF T_MVKE-MATNR OR T_MVKE-VKORG.
    IF T_MVKE-VKORG = '2000' and SY-TABIX > 1.
          CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
    ELSEIF T_MVKE-VKORG = '2000' AND SY-TABIX = 1.
         CONCATENATE '2000' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
    ELSE.
        CONCATENATE '2100' 'TS' P_WERKS T_FINAL-MATNR INTO KEY.
        ENDIF.
    this logic fails ,. could tell me how to compare values in single itab?
    Thanks
    neha

    Hi ,
    if i've understand you correctly , try that:
    LOOP AT t_final.
      AT NEW matnr.
        CLEAR: v_2000, v_2100.
    *1) 2000
        READ TABLE  t_mvke    WITH KEY matnr = t_final-matnr
                                       vkorg = 2000.
        IF sy-subrc = 0.
          v_2000 = 'X'.
        ENDIF.
    *2) 2100
        READ TABLE  t_mvke    WITH KEY matnr = t_final-matnr
                                       vkorg = 2100.
        IF sy-subrc = 0.
          v_2100 = 'X'.
        ENDIF.
    *compare
        IF v_2000 = 'X' AND  v_2100 = 'X'.
    *read 2000 only
        ELSEIF v_2000 = ' '  AND v_2100 = ' '.
    *nothing found
        ELSE.
    *all other combinations
    *read 2100 only
        ENDIF.
      ENDAT.
    ENDLOOP.
    regards Andreas

  • How to compare 2 arrays with different operator options using parameters in Teststand

    Pls let me know how to compare 2 arrays using different operators like <= or >= or ==......

     I am using TS 2010. FYI
    ex:
    Array XX [ A_Temp,
                   B_Temp,
                   C_Oil Pressure,
                   D_Oilpressure,
    Note : A_Temp, B_Temp,C_Oil Pressure,D_Oilpressure all these parameters will be getting  numerical values (dynamically) from the simulink models and also in future I may need to add parameters to this array.
    Array YY [A_Temp_1,
                   B_Temp_2,
                   C_Oil Pressure_3,
                   D_Oilpressure_4,
    Note : A_Temp_1, B_Temp_2,C_Oil Pressure_3,D_Oilpressure_4 all these parameters will be getting  numerical values (dynamically) from the simulink models
    So my question :
    I would like to verify A_Temp >= A_Temp_1
                                B_Temp >= B_Temp_2
                                C_Oil Pressure  >= C_Oil Pressure_3  etc

  • How to ask for an array and how to save the values

    I'm supposed to be learning the differences between a linear search and a binary search, and the assignment is to have a user input an array and search through the array for a given number using both searches. My problem is that I know how to ask them how long they want their array to be, but I don't know how to call the getArray() method to actually ask for the contents of the array.
    My code is as follows:
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How long would you like the array to be?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            System.out.println("Please enter the first value of the array");
        public static void getArray(int List[], int arrayLength)
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter the next value for array");
                 List[i] = input.nextInt();
         public static void printArray(int List[])
             for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
    public class search
        public static int binarySearch(int anArray[], int first, int last, int value)
            int index;
            if(first > last) {
                index = -1;
            else {
                int mid = (first + last)/2;
                if(value == anArray[mid]) {
                    index = mid; //value found at anArray[mid]
                else if(value < anArray[mid]) {
                    //point X
                    index = binarySearch(anArray, first, mid-1, value);
                else {
                    //point Y
                    index = binarySearch(anArray, mid+1, last, value);
                } //end if
            } //end if
            return index;
        //Iterative linear search
        public int linearSearch(int a[], int valueToFind)
            //valueToFind is the number that will be found
            //The function returns the position of the value if found
            //The function returns -1 if valueToFind was not found
            for (int i=0; i<a.length; i++) {
                if (valueToFind == a) {
    return i;
    return -1;

    I made the changes. Two more questions.
    1.) Just for curiosity, how would I have referenced those methods (called them)?
    2.) How do I call the searches?
    import java.util.Scanner;
    import java.util.ArrayList;
    public class Main
        private static Scanner input = new Scanner(System.in);
        public static void main (String args[])
            //creates ArrayList
            int List[];
            System.out.println("How many values would you like the array to have?");
            int arrayLength = input.nextInt();
            //Initializes array list
            List = new int [arrayLength];
            //Collects the array information
            for(int i=0; i < arrayLength; i++) {
                 System.out.println("Enter a value for array");
                 List[i] = input.nextInt(); 
            //Prints the array
            System.out.print("Array: ");
            for(int i=0; i < List.length; i++)
                 System.out.print(List[i] + " ");
            //Asks for the value to be searched for
            System.out.println("What value would you like to search for?");
            int temp = input.nextInt();
            System.out.println(search.binarySearch()); //not working
    }

  • How to compare, current value in :block.text_item with the database value

    Hi
    Could you please tell me
    How to compare the current value in :block.text_item with the corresponding database column value.
    I am using forms 10g
    There is block and there is an text Item in that block.
    When I run the form and query the block (tabular), the :block.text_item shows me, whatever value there in the database.
    Now I add some value in the :block.text_item to the existing value.
    now
    the :block.text_item contains old+ new added value
    whereas
    the database table contains 'old' value
    Now on a button click , I want to find out what is the value that I have added
    Could you please tell me, is it possible without writing a select query?

    Hello,
    Now on a button click , I want to find out what is the value that I have addedSo you mean always user will add value in the existing value. Because this way will fail in one case. Let say
    Value in Database is = ABCD
    User opened the form and he removed the D and write E and now value is ABCE and length is still same 4. So, there is no addition.
    Anyway you can know the database value at runtime there is one property for item called DATABASE_VALUE. It gives the value which is in database while you are running the form before save. and you can use like this..
    Trigger = WHEN-MOUSE-DOUBLE-CLICK on item level
    DECLARE
      vItemValue DATATYPE; -- Set the data type according to your desired field.
      vValueAdded DATATYPE; -- Set the data type according to your desired field.
    BEGIN
      vItemValue:=GET_ITEM_PROPERTY('ITEM_NAME',DATABASE_VALUE);  -- It will return you the database value in vItemValue variable.
      IF LENGTH(vItemValue)>LENGTH(:FORM_ITEM_NAME) THEN  -- It mean something change or added
        vValueAdded:=SUBSTR(:FORM_ITEM_NAME,LENGTH(vItemValue)+1);
        MESSAGE('Added value is : '||vValueAdded);  -- It will show you the added value.
      END IF;
      -- now suppose you want to show the old and new value in message not the added one
      -- Then no need of IF condition. You can just use message like this
      -- And i would prefer to use like this way
      MESSAGE('Old Value : '||vItemValue||'  New Value - '||:FORM_ITEM_NAME);
      MESSAGE('Old Value : '||vItemValue||'  New Value - '||:FORM_ITEM_NAME);
    END;Hope it is clear.
    -Ammad

  • How to compare time values

    Friends
    Could some one help me with Time values...
    I would like to compare two time values one of which is stored as a string. so i would like to how to compare the system time with another column which has a string stored in time format..
    i mean Sysdate - 10:30:00
    Thanks in advance..

    select 'Y' from dual
    where to_char(sysdate, 'HH24:MI:SS') = '10:30:00'
    SQL> ed
    Wrote file afiedt.buf
      1  select 'Y' from dual
      2* where to_char(to_date('10-02-2006 10:30:00', 'DD-MM-YYYY HH24:MI:SS'), 'HH24:MI:SS') = '10:30:0
    SQL> /
    Y
    SQL> Cheers
    Sarma.
    Message was edited by:
    Radhakrishna Sarma

Maybe you are looking for