Average of all values between (first above and last above) a threshold value.

Currently I have a VI which I programmed a year or more ago, which grabs any value out of a data set that is above a threshold value. This is used for capturing the average of all values over a threshold when there is one peak of values that go above that threshold. However, when there are two or more peaks that go above this threshold, only the values above that value are averaged, so the end result is the average of two or more averages.
What I need is for every value that occurs after the threshold is reached and before the threshold is dropped below for the last time. Picturing a set of data whose graph looks like the letter "M," for example with the threshold being halfway up the M, I want to show the average of (the first hump, plus the dip below the humps, plus the last hump) but what I'm getting now is the average of (the first hump, plus the last hump). What I get now cuts out the data between the two peaks.
Any assistance would of course be appreciated.
Solved!
Go to Solution.
Attachments:
AveAboveThresholdAll.vi ‏15 KB

Actually I think that Tims solution has a little difference to the stated problem that both limits should be above a threshold value. Since the second array is inverted the rounding should be not towards +Infinity but towards -Infinity in order to really only go up to the last element that is above the threshold. The code as made by Tim takes one sample more, which could or couldn't have any significance.
Nevermind, I take that back.
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions

Similar Messages

  • Why does text field in InfoPath 2010 show user name with two commas between first name and last?

    Here's the problem. I have a text field called Manager in an InfoPath 2010 form that is getting populated by a drop down field called
    Business Unit.
    The Business Unit drop-down field is pulling information from
    column A in a custom list via a managed data connection. The custom List has two columns:
    Title & Manager. 
    The Manager column in the custom list is a 'Person or Group' type column.
    The Data Connection pulls both the Title, Manager
    (and ID) data.
    There is a rule on the Business Unit drop-down field to change the value of the
    Manager text field with the Manager data on the custom list. The rule pulls the
    Manager information and filters the value to match the
    Business Unit on the Data Connection with the Business Unit drop-down
    field value (Main).
    The Business Unit drop-down field works great and pulls the value from the custom list, and the rule populates the Manager text field. The problem is that Manager text field shows the name as such:
    [smith,, john]. Notice the two commas between the last and first name. There should only be
    one comma!
    Anyone have an idea why the text field is appearing with two commas?
    Arnel

    Hi all,
    I have a workaround for this. I have an InfoPath 2010 form pulling data from a SP2010 list. The user chooses a System (Business Unit) from the dropdown list and that choice auto populates the associated user (Manager) for that system. I had to
    use concatenation, substring before and substring after to display the correct data.
    concat(substring-before(DisplayName, ",, "), ", ", substring-after(DisplayName, ",, "))
    DisplayName is the original data for the field. I am able to cut & paste this field into the formula. Therefore, I added a few spaces to separate it from the actually formula for future use.
    Select Insert Function
    Select concat
    Select the first link to double-click to insert field
    and then select Insert Function
    Select the Text category and choose substring-before
    Select the third link to double-click to insert field
    and then select Insert Function
    Select the Text category and choose substring-after
    Copy and paste your fieldname (in my case DisplayName) in the
    double-click to insert field
    parts of the substring-before and substring-after links.
    Delete the middle double-click to insert field link
    Add quotes, spaces and commas so that they match the following format:
    concat(substring-before(DisplayName, ",, "), ", ", substring-after(DisplayName,
    Translation:
    concat(substring-before(Doe,, John, ",, "), ", ", substring-after(Doe,,
    John, ",, "))
    Bring together all of the text before ",," (i.e. Doe) with ", " (comma, space) and all text after ",," (i.e. John).
    It should return
    Doe, John.
    I hope this makes sense. I have these instructions with screenshots if you need them, contact me.

  • SQL select Statement -first day and last day of the month - 1 year from now

    Hi,
    I need to write a SQL to get the dates in between first day and last day of the month one year from now.
    SELECT last_day(add_months(sysdate,12)) as lastday from dual
    What could be the Query to get the first day of the month one year from now..
    ie ..Sysdate - 3-DEC-2009
    Result - 1-DEC-2010
    thank you

    Hi,
    You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
    SELECT  TRUNC ( ADD_MONTHS ( SYSDATE
                               , 12
                  , 'MONTH'
                  )     AS first_of_month
    FROM    dual
    ;The DATE returned will be in the same month, year, quearter, ... as the first argument.
    \We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
    At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
    For example, to find all appointment_dates in the current month next year:
    SELECT  *
    FROM    appointments
    WHERE   appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
    AND     appointment_date <  TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
    the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
    the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.

  • All differences between a function and a procedure.

    What are All differences between a function and a procedure.

    What are All differences between a function and a procedure.This is basic procedural programming fundamentals that you should learn at school.
    A function is a procedure that returns a value (of the type defined in the function declaration) using the RETURN statement at the terminal point of the processing code.
    That's the only difference.
    In terms of SQL, procedures cannot be used within SQL and functions can, but only if the function does not contain any OUT or IN OUT parameters and the return type is of a supported SQL type.

  • JTable SelectionModel - first Index and Las Index giving incorrect values

    Hi Guys,
    When i added a ListSelectionListener to the JTable's selectionModel, and tried to get the first index and last index values. The goofy thing i noticed is when you select different rows, the indexes are correct,but when you switch between the same rows, then indexes provided by the ListSelectionListener are always the same. Example : if you switch between 3 and 4 rows first index is 2 and last index is 3 which is correct, but if you go back 3rd row from 4th row, the first index is still 2 and last index is 3... which is kind of weird.
    Any ideas about this, and why this is happenning.
    I am pasting my sample code here any explanation is very helpfull to understand this behavior
    Thanks
    Nicedude
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JComponent;
    import javax.swing.ListSelectionModel;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import java.awt.Dimension;
    import java.awt.GridLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    * SimpleTableSelectionDemo is just like SimpleTableDemo,
    * except that it detects selections, printing information
    * about the current selection to standard output.
    public class SimpleTableSelectionDemo extends JPanel {
         private boolean DEBUG = false;
         private boolean ALLOW_COLUMN_SELECTION = false;
         private boolean ALLOW_ROW_SELECTION = true;
         public SimpleTableSelectionDemo() {
              super(new GridLayout(1,0));
              final String[] columnNames = {"First Name",
                        "Last Name",
                        "Sport",
                        "# of Years",
              "Vegetarian"};
              final Object[][] data = {
                        {"Mary", "Campione",
                             "Snowboarding", new Integer(5), new Boolean(false)},
                             {"Alison", "Huml",
                                  "Rowing", new Integer(3), new Boolean(true)},
                                  {"Kathy", "Walrath",
                                       "Knitting", new Integer(2), new Boolean(false)},
                                       {"Sharon", "Zakhour",
                                            "Speed reading", new Integer(20), new Boolean(true)},
                                            {"Philip", "Milne",
                                                 "Pool", new Integer(10), new Boolean(false)}
              final JTable table = new JTable(data, columnNames);
              table.setPreferredScrollableViewportSize(new Dimension(500, 70));
              table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
              if (ALLOW_ROW_SELECTION) { // true by default
                   ListSelectionModel rowSM = table.getSelectionModel();
                   rowSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                             //Ignore extra messages.
                             if (e.getValueIsAdjusting()) return;
                             ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                             if (lsm.isSelectionEmpty()) {
                                  System.out.println("No rows are selected.");
                             } else {
                                  int selectedRow = lsm.getMinSelectionIndex();
                             System.out.println("Row " + selectedRow + " is now selected.");
                                  int first = e.getFirstIndex();
                                                            int last = e.getLastIndex();
                              System.out.println(" First Index is : " + first);
                              System.out.println(" Last Index is : " + last );
              } else {
                   table.setRowSelectionAllowed(false);
              if (ALLOW_COLUMN_SELECTION) { // false by default
                   if (ALLOW_ROW_SELECTION) {
                        //We allow both row and column selection, which
                        //implies that we *really* want to allow individual
                        //cell selection.
                        table.setCellSelectionEnabled(true);
                   table.setColumnSelectionAllowed(true);
                   ListSelectionModel colSM =
                        table.getColumnModel().getSelectionModel();
                   colSM.addListSelectionListener(new ListSelectionListener() {
                        public void valueChanged(ListSelectionEvent e) {
                             //Ignore extra messages.
                             if (e.getValueIsAdjusting()) return;
                             ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                             if (lsm.isSelectionEmpty()) {
                                  System.out.println("No columns are selected.");
                             } else {
                                  int selectedCol = lsm.getMinSelectionIndex();
                                  System.out.println("Column " + selectedCol
                                            + " is now selected.");
              if (DEBUG) {
                   table.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent e) {
                             printDebugData(table);
              //Create the scroll pane and add the table to it.
              JScrollPane scrollPane = new JScrollPane(table);
              //Add the scroll pane to this panel.
              add(scrollPane);
         private void printDebugData(JTable table) {
              int numRows = table.getRowCount();
              int numCols = table.getColumnCount();
              javax.swing.table.TableModel model = table.getModel();
              System.out.println("Value of data: ");
              for (int i=0; i < numRows; i++) {
                   System.out.print("    row " + i + ":");
                   for (int j=0; j < numCols; j++) {
                        System.out.print("  " + model.getValueAt(i, j));
                   System.out.println();
              System.out.println("--------------------------");
          * Create the GUI and show it.  For thread safety,
          * this method should be invoked from the
          * event-dispatching thread.
         private static void createAndShowGUI() {
              //Make sure we have nice window decorations.
              JFrame.setDefaultLookAndFeelDecorated(true);
              //Create and set up the window.
              JFrame frame = new JFrame("SimpleTableSelectionDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              //Create and set up the content pane.
              SimpleTableSelectionDemo newContentPane = new SimpleTableSelectionDemo();
              newContentPane.setOpaque(true); //content panes must be opaque
              frame.setContentPane(newContentPane);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
    }

    >
    I was (maybe wrongly) under the impression that, last index will give the last selected value and first index will give me the currect selected value. Not maybe - your impression sure is wrong. Honestly can't understand how it's possible to mis-interpret the api doc of ListSelectionEvent (except not reading it ;-)
    "Represents a change in selection status between firstIndex and
    lastIndex, inclusive. firstIndex is less than or equal to
    lastIndex. The selection of at least one index within the range will
    have changed."
    Jeanette

  • Problem exchanging values between a Servlet and Thread???

    Hi Everybody,
    I have got a problem exchanging values between a Servlet and a Thread...
    The actual thing will go like this
    I take a request from JSP which is served by a servlet..
    A thread is invoked in the servlets into which the parameter values taken from JSP page is sent...
    In between the thread needs to be suspended for a moment, relieve the control back to the servlet and then come back with the new values modified in the servlet...
    How is this achieved?
    Please give ur suggestions regarding this...
    Thanks in advance

    I really have no clue how you can use URLConnection to do that!
    Could you please explain in the following scenario how it can help me as an alternative solution to the following:
    Non-Servlet A continously running & saving to some prop regularly
    --> servlet B reads prop file regularly --> display continously on a jsp file
    I wish I could do a servlet A --> servlet B-- > display jsp scenario but I do not know how to have servlet A continously running while keep the servlet B interacting with the jsp.

  • First name and last name order in contact list

    Actually, my contact list is displayed with the last name before the first name, but everything is fine in Address Book settings (I choosed "First name, Last name" option), and I checked that first name and last name has not been reversed for some reasons between two fields, the first name is right in place, as is the last name.
    So changing this is AddressBook has no effect.
    I tried disabling Chax, without success.
    It could be possible this problem occured when I enabled Microsoft Exchange address book synchronization, (iSync reported 500+ changes in AB database, I did it anyway and noticed no problems in data after synchronization (I still have a backup :-))
    One more thing , the displayed name in the iChat menu extra is correct.
    So, what could possibly change this behavior I did not already check ?
    Powerbook Aluminium 15" 1,2GHz | iPod | iPod Shuffle | iSight | MX900   Mac OS X (10.4.6)  

    Hi Yann,
    If you add details to the Address card in iChat as you add a Buddy then you need the first set of instructions I posted.
    You nee this menu in iChat http://www.flickr.com/photos/90943061@N00/135575605/
    In the second section of this menu you can sort the list.
    <hr>
    Ahhh. I see what you mean.
    iChat does in fact always display First Name, Last Name as you say.
    Adding a Buddy with the names in the reverse order to display as you want in iChat your Address book gets messed up as it is not consistent with those contacts that are not iChat Buddies.
    The only work around I can see is to change all the Address Book entries to match a reverse entry in iChat and then use the Address Book option to display Last Name, First name to show them the 'correct' Fist name, Last name and have them in Last name, First name in iChat.
    11:06 PM Wednesday; April 26, 2006

  • Function module(first name and last name as a parameter with table)

    hi,
    i just want to know how i match input value in function module with the self created ztable first name and last name as a parameter in function module(import).
    regards
    Ankur

    thanks for your help actually i am concatename first_name last_name into full_name
    import parameter
    FIRST_NAME like ZANKUR-FNAME first name
    LAST_NAME like ZANKUR-LNAME last name
    export parameter
    full_name like zankur full name
    excaption
    error if name not matched
    source code
    concatename first_name last_name into full_name

  • Function Module to get pernr number based on first name and last name

    Hi All,
    What is the Function Module to get pernr number based on first name and last name.
    Could you please help me.
    T@R.
    Vidya

    hi Vidya,
    you can get perner from PA0002 based on firs name and last name.
    use select query and get perner.

  • Alternative for first-child and last-child

    Hi all,
    I am looking to style a ListView with rounded corners (similar to iOS), but so far, I have not been able to find a way to do this without first-child and last-child pseudoselectors, which are not supported in JavaFX, according to http://docs.oracle.com/javafx/2/api/javafx/scene/doc-files/cssref.html.
    Simply setting rounded corners on a ListView causes the ListCells to pop out, unless I set rounded corners on them as well. But I only want to to this on the top and bottom child.
    Does anyone have a workaround for this ?

    Can't you solve it by setting a border on the top and the bottom of your listview?

  • Auto generate login name basis on user first initial and last name... LC designer

    First initial + last name= login name...
    Text field   + text field  = text field....
    can I use javascript to generate the loginname form first name (first Int) and last name???
    For ex... First name: John
                 middle int: k
                 last Name: Doe
                LoginName: jdoe
    var LoginName = getField("LastName").value;
             var FirstName = getField("FirstName").value;
             if (FirstName!="")
             LoginName += " " + FirstName.substring(0,1) + "."
             event.value = LoginName;
    not sure if this is right... please help

    You guys are both using Acrobat JS notation so you're not going to have much luck.
    In LC there's no getField or event.value and values are returned from fields using fieldName.rawValue (or .formattedValue).
    I put this on the Calculate event of the LoginName field:
    var vFirstName = FirstName.rawValue;
    var vLastName = LastName.rawValue;
    if (!(FirstName.isNull || LastName.isNull)) { // if both fields have data
    this.rawValue = vFirstName.substring(0,1) + vLastName;

  • The difference between system restore and last good known configuration

    hi,
    what is the difference between system restore  and last good known configuration.
    in which situation you use system restore ,and in which situation you use last good known configuration.
    very short answer wil be enough.
    thanks
    johan
    h.david

    Last Known Good Configuration deals only with Starting Windows eg. a bad registry or incorrect driver is preventing Windows to start.It recovers the registry settings of HKEY_LOCAL_MACHINE\System\CurrentControlSet
    While System Restore uses restore points to return your system files and settings to an earlier point in time without affecting personal files. Restore points are created automatically every week, and just before significant system events, such as the installation
    of a program or device driver. You can also create a restore point manually.You can undone system restore but there is no such option in Last Known Good Configuration.
    Last Known Good Configuration is disabled in Windows 8 or,Windows 8.1 by default.
    Try using Last Known Good Configuration if you can't start Windows, but it started correctly the last time you turned on the computer.
    Try using System Restore to return the system to an earlier point in time when things worked correctly.
    S.Sengupta, Windows Entertainment and Connected Home MVP

  • History - turn on columns "First Visited" and "Last Visited" replacing/instead of "Visit Date"?

    Sometime before Firefox 3.x, in the History window -- it would show you columns of "First Visited" and "Last Visited".
    Now you only get "Visit Date" which is equivalent to "Last Visited".
    * Question -- anyone know how to bring back the "First Visited" column to the History window?
    * I looked in about:config and couldn't find anything.
    * I searched for a Addon and didn't find a current one. (There used to be an Addon called Extended History Manager that would show that column but an administrator disabled the download page for it.)
    * Anyone know how to bring back the "First Visited" column?
    Having that column by default in the Mozilla suite browser. (pre Firefox) was awesome! And at least in Firefox 1 and 2 you could use Extended History Manager Addon. I miss "First Visited"! :(

    Hi Fractalogic, this support forums doesn't work very well as a suggestion box because of the volume of posts and the audience reading it. You can try the following to get more visibility on the proposal:
    * Help > Submit Feedback
    * Filing a request for enhancement on https://bugzilla.mozilla.org/
    You might also try recruiting any developer that created a useful history-related add-on to incorporate this feature.

  • In which table I can get the Contact full name(First name and Last name)

    Hi,
    In  which table, I can get the field for Contact Person Full  name. In many tables Iam seeing FIRST NAME and LAST NAME as two fields.
    Regards
    Babu.

    You can use FM "CRM_BUPA_DESCRIPTION_READ".
    regard,
    vijay.

  • Anyone have problems with apple ID's? I have the correct ID in my settings but when I try to update my apps my ID shows my first name and last name but not my ID? I'm not sure what else to do because I've made sure I have the correct ID in my settings!

    Anyone have problems with apple ID's? I have the correct ID in my settings but when I try to update my apps my ID shows my first name and last name but not my ID? I'm not sure what else to do because I've made sure I have the correct ID in my settings! Anyone else have this issue?

    I think its meant to show your name, not your ID.

Maybe you are looking for