Finding the first maximum in a 1D array

Hello evryone!!
I have a huge 1D array and It has certain values which are like peaks when plotted. For example, the array may look like:
1 0.23 0.12 0.34 0.2 1.345 0.25 0.13 0.45 0.16 1.023 ---- As you can notice, the array has maximum values  (magnitude close to 1) placed regularly. Now I need to find each of these maximum value and put them in an array. Currently I just start at iteration 0 of the array and use the array index function to get all of these peaks.
However,in this code, I assume that the first maximum peak occurs at element 0 (first iteration) of array. But this may not be the case and the array might look like:
0.23 0.12 1 0.24 0.34 0.15 0.19 1.023 0.45 0.51 0.21 0.3 1.345....etc. that is the first maximum value may not occur at the element 0 of the array. So the problem here is to find this first maximum peak and then as the others are placed at regular intervals, i can find them.
Could any one please suggest as to how i could change my code to find this first maximum/peak. thanks for the help  

LSASS wrote: 
You may not have observed their regular appearance becuse the peaks are seperated by 584 values which is huge.
I could not observe anything, because the original VI had no data at all and was not executable because of missing subVIs!
Why don't you simply get the index of the first element that is above e.g. 0.5 as in the attached quick draft (LV 8.6)? Modify as needed.
(I also did some general cleanup, your code was way too complicated, e.g. way too many loops! )
LabVIEW Champion . Do more with less code and in less time .
Attachments:
receiver_constMOD.vi ‏36 KB

Similar Messages

  • RAID Fails to find the first device

    Hello all.
    This is my first post to the forum. I did a brief search but i couldn't find any good results, so i tought i'd post my prob here.
    I have an MSI K7N2 Delta2-LSR motherboard, with a 450W PSU (i don't have any more info on that yet), 2x512MB RAM DDR 400 (no more info on that one yet either), 2x120GB SATA WD HD, 1xDVD TEAC, 1xDVD+-RW SONY DL, 1x1.44MB FDD, an ATI RADEON 9600 PRO ALL-IN-WONDER VGA card on an nForce chipset.
    The first HD has WinXP installed on it with the raid drivers installed properly. The second HD has Mandrake 10.1 Linux installed on it.  They are installed as separate arrays.
    The problem I'm having is that while I'm working in Windows, after a while the computer completely freezes. The only possible way out of it is to reset the machine. After I do that, at the boot screen, it fails to find the first HD (the one with WinXP on it). If i turn it off for let's say 5 minutes, and boot up, it detects the HD again and goes on loading windows. After I log in i have at maximum 5 minutes before it freezes again.
    It does this every time. The more time I leave my PC turned off, the longer time it will take to freeze again when I'm logged in WinXP. I formatted the HD many times, installing every possible combination of my drivers but the problerm persists. Although it has never happened anything like that in Linux.
    Could it be the RAID Controller (onboard), the WD HDD, or the Motherboard in general?
    What can I do to find out what the problem is? And if possible, how to solve it?
    If more info is needed, I will update the info of my pc as soon as I get back home.
    P.S. I cheched the WD HDD, using WD tools like Disk Diag, etc. It never gave me any problems. I also used UBCD for win, and cheked the disk, to dicover once again, that the disk supposingly has no problems.
    Any help would be appreciated.
    Thanks in advance.

    of its label Power Supply Guide
    i suspect the drives bad
    go to wd site and look for their drive tester

  • Finding the 25th largest number in an array

    How would I say find the 25th largest number in an array?
    Or nth largest number?
    Chris

    I find most of these answers correct, but without previous knowledge of the size of the array, I would do things differently.
    In the enclosed VI, a cluster is formed of all array values and their index. When the array is then sorted, the first cluster element is used as the first sort criterium, then the second cluster element. This allows a single array operation (Sorting) to take care of any searching, whilst the cluster retains the index of the original array.
    Coupling this method with an unitialised shift register, you can also cache the sorted array to allow for more rapid processing if you require more than a single indexed value.
    Another way to achieve this is (Assuming you`re seeking the 25 largest) to simply get the max and min at t
    he very beginning, feed the array into a loop with a shift register, set the value at the index returned for max each run to the initial min value -1, and repeat another 24 times.
    Regarding memory use and execution speed, I`m not sure if searching an array 25 times is quicker than a single sort or not (No new array is created), but both versions are viable.
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Get_Nth_largest-smallest_(6.1).vi ‏31 KB
    Get_Nth_largest-smallest_(6.1)_-_version_2.vi ‏42 KB

  • I need help writing a script that finds the first instance of a paragraph style and then changes it

    I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style.  I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style.  Any help would be greatly appreciated, thanks!

    Hi,
    Do you mean first instance of the paragraph style
    - in a chosen story;
    - on some chosen page in every text frames, looking from its top to the bottom;
    - in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
    If story...
    You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
    Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
    so:
    Story.findText()[0].appliedParagraphStyle = Style_1;
    //==> this will change a paraStyle of 1st occurence of story to "Style_1".
    If other cases...
    You would need to be more accurate.
    rgds

  • How can I find the local maximum in each interval from a graph?

    I have very less experience in labview and need some helps. I am currently using Labview 2013.
    I am analysing a very big data file. I want to find the  values of the local maximum (the peak) in every 1000 data points. Is there anyway to do it?
    I also want to have a control on when to start finding the local maximum point (after 10000 data points) and when to end it ( at 30000 data points)
    The attachment is a very similar graph of what I am analysing.
    Thank you very much.
    Attachments:
    A06-1-11_1.xlsx ‏642 KB

    Hi John,
    save that Excel spreadsheet as CSV file (form Excel).
    The use ReadFromSpreadsheetFile to load the data into LabVIEW. Now you get an array of data and you can do anything with it.
    - You might use a loop to pick an ArraySubset of each 1000 datapoints and analyze it.
    - You might use numeric controls to provide an input for the user...
    Where's your problem? It seems you already know where the goal is...
    And try to THINK DATAFLOW! You don't want to analyze data from a graph, you want to analyze spreadsheet data. A graph is just a data sink (in LabVIEW)...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Find the first occurance of a word

    I have a script which finds and counts ALL occurances of a word.
    I need the script to find the FIRST instance of a word only.
    Can any one please advise how to modify the script to find the first instance of the word?
    Script as follows:
    var numWords = this.getPageNumWords(0);
    for (var i=0; i<numWords; i++)
    var ckWord = this.getPageNthWord(0,i);
    if ( ckWord == "MATERIAL")
    /*Script will go here based on finding the first instance of the word "MATERIAL"*/
    I have tried var CKWord = this.getPageNthWord(0,0); but console reports back is UNDEFINED?

    Thanks for your help.  Script now returns the first occurance of the word "MATERIAL".
    I know have to add to the script to find the SECOND OCCURANCE of the word "ISSUED".
    Can you please advise how I would code the script for this, ie would this have something to do with the break command?
    var numWords = this.getPageNumWords(0);
    for (var i=0; i<numWords; i++)
    var ckWord = this.getPageNthWord(0,i);
    if ( ckWord == "ISSUED")
    var coord = this.mouseX;
    var annot = this.addAnnot({
    page: 0,
    type: "Stamp",
    name: "AppStamp",
    rect: [coord+1000, 2300, 30, 2820],
    rotate: 90,
    AP: "#C94cHAFFa42U1gTH5Tug5C" }); 
    /*break; how can this be modified to break for the second occurance of the word "ISSUED"?*/

  • Query to find the  second maximum date in a table

    please give me the query to find the second maximum date in a table

    You can try with this
    SELECT empno
          ,hiredate
      FROM emp        a
    WHERE 2          = (SELECT COUNT(DISTINCT hiredate)
                           FROM emp        b
                          WHERE b.hiredate      >= a.hiredate
    OR
    SELECT empno
          ,hiredate
      FROM (SELECT ROWNUM      row_num
                  ,empno
                  ,hiredate
              FROM emp        a
          ORDER BY hiredate   ASC
    WHERE row_num             = 2;Regards
    Arun

  • How to find the First block....in a multi block form

    hi
    How i can find which is the first block in a multi block form....
    ( there are n number of forms with multi blocks...so
    i need to generalise the code to find the first block in all of
    the forms)
    regards
    Kris

    If you searched in the on-line help for "First", you would find that the Get_Form_Property built-in provides two: First_Block and First_Navigation_Block.

  • Finding the most common value in an array of enums

    Hello,
    I'm looking for an elegant way of finding the most common value in an array of enums
    My enum being:
    0 - Close
    1 - Open
    2 - Undefined
    For instance, if my array contains:
    Close, Close, Open, Close, Close, Open.
    The most common value would be "Close"
    I have created a very customized VI that allows me to obtain the desired result, but I'm really not proud of doing it this way, simply because I would have to modify it if I were to add a new value to my enum...
    If someone can share some ideas to enlighten me, I would REALLY appreciate it.
    Thanks in advance!
    Jorge
    Solved!
    Go to Solution.

    Here is the variant using the search method. This method will run N-1 times where N is the number of ENUM elements. Yes, it is a bit more complex than the brute force method but it would execute fairly quickly. The sort would probably be the time consuming task.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot
    Attachments:
    ENUM Counter.vi ‏14 KB
    Enum.ctl ‏4 KB

  • HT203167 i have purchased 100 songs in last 2 years on itunes  now i am able to find the first 50 songs i am using the original id in all my devices.i even got the invoice of my purchase where can find them all?

    i have purchased 100 songs in last 2 years on itunes  now i am able to find the first 50 songs, i am using the origial id in all my devices.i even got the invoice of my purshace where can find them all?
    ITS NOT EVEN SHOWING UP IN PURCHASED SECTION

    1. iTunes won't offer cloud downloads for songs that it "thinks" are in your library, even if it "knows" the files are missing. If you've exhaustively searched for the missing files and there is no prospect of repair by restoring to them to their original locations, or connecting to new ones, then delete that tracks that display both the missing exclamation mark and are of media kind Purchased/Protected AAC audio file. Don't hide from iTunes in the cloud when asked, close iTunes, then reopen. You can download from the cloud links or iTunes Store > Quicklinks > Purchased > Music > Not on this computer > All songs > Download all.
    2. Why? Not sure, perhaps 3rd party tools or accidental key presses combined with previously hidden warning messages when trying to organize the library. There is a hint that using the feature to downsample media as it is synced to a device may also be involved, though I've not replicated it. Whatever the reason a backup would protect your media.
    tt2

  • UDF for Find the First letter from Input

    Hi Masters,
    I want find the first letter from input, Can any one help me on this..UDF or any solution.
    Ex: E2HB means - Alpha Letter is the first
    Ex: 1234 means - Number is the first
    Thanks,
    Siva

    Hi Siva,
                I just want to clarify this doubt, you want the first character of the string you pass to the UDF i.e if input="E2HB"  output="E"   and if input="1234"   output="1". If my assumption is correct you can try the UDF "firstChar" I have shown below this gives exactly the output you want
    public class firstLetter {
         public static String firstChar(String s)
              if(s==null)
                   return null;
              if(s.equals(""))
                   return s;
              String t="";
              t+=s.charAt(0);
              return t;
         public static void main(String[] args) {
              String s1="E2HB",s2="1234";
              s1=firstChar(s1);
              System.out.println(s1);
              s2=firstChar(s2);
              System.out.println(s2);
    Regards
    Anupam

  • Finding the first unused number in a column

    I am attempting to write a single SQL statement that can find the first unused number for a column. For example, for a column called BLOCKID, that contains these values...1,2,3,4,6,7,8...I would like to be able to insert a record with BlockID equal to 5. I can do this by writting a loop, but that seems quite inefficient (may have to loop hundreds of times or more to find the first available hole).
    Any ideas? Thanks, Kieren
    null

    Here's one way
    1. Get a list of row numbers for the table
    2. Add an item to the list for 1 more than the largest id
    3. Remove from the list all numbers already used
    4. Use the smallest value of the list that is left.
    As a query this would be:
    SELECT MIN(BLOCKID) FROM
    (SELECT MAX(BLOCKID) + 1 BLOCKID
    FROM mytable UNION ALL
    SELECT ROWNUM BLOCKID
    FROM mytable MINUS
    SELECT BLOCKID FROM mytable
    Needless to say there should be a primary key or index on the BLOCKID column of 'mytable'.
    Good luck!
    null

  • Where can i find the first iPhoto

    Where can i find the first iphoto?

    Best if you try and explain what you are trying to acheive.
    Iphoto is a different paradigm than you're used to. I don't understand why you are trying to transfer your edited photos back to an external disk.
    There are tutorials here
    http://www.apple.com/findouthow/photos/
    Regards
    TD

  • IDOCS - Finding the first error message when reprocess has been done 17000 times

    I was hoping for some assistance. We have an automated reprocessing of our iDocs in one interface. I would like to find the first error message at status 51 in order to see the failure messge. Since the idocs have been reprocessed so many times, it cannot be found in the iDoc handler. Please advise if you have tips.

    This message looks like homemade. And the message will not change, no matter how often you repost the same IDOC without having changed anything.
    So you should at least see the message number to this message in the EDIDS table
    You can search SCN using this number, you can search for OSS notes with this number, or you get active yourself in SAP and check the where used list from SE91 transaction to know in which program this error is triggered and under what circumstances

  • How to find the last element of a byte array

    Dear all,
    I have a byte array with a max lenght of 1024*50 bytes. In that array I store the bytes read from a file. How can I find where the array ends (i.e. which is the last valid element of the byte array)?
    Thank you for your help.
    Best Regards,
    JIM

    I want to send files over TCP connection using BufferedOutputStreams and BufferedInputStreams. The first side (e.g. the client) sends a file (e.g mp3 file or jpeg image) to the server using the code
      public void sendFile(Socket s, String FileName) throws Exception
              BufferedOutputStream out = new BufferedOutputStream(s.getOutputStream());  
              BufferedInputStream in = new BufferedInputStream(new FileInputStream(FileName));
              int len = 0;
              while ( (len = in.read(buffer)) > 0) {
                out.write(buffer, 0, len);
              in.close();
              out.flush();
            }(The client does not close the BufferedOutputStream out because other files will be sent afterwards)
    Then, the server receives the file using the code:
            public void receiveFile(Socket s, String FileName) throws Exception
              OutputStream out = new BufferedOutputStream(new FileOutputStream(FileName)); 
              InputStream in = new BufferedInputStream(s.getInputStream());
              int len = 0;
              while ( (len = in.read(buffer)) > 0) {
                out.write(buffer, 0, len);
                break;
              out.flush();
              out.close();
            }(likewise the InputStream in is not closed for the same reasons).
    In order the server to receive the file and stop reading the BufferedInputStream, I will have to make some modifications to this part of the code,
    while ( (len = in.read(buffer)) > 0)so as to know when the whole file has been received.
    Thus, even if I send the length of each file, I will not be able to read it. Could you please recommend me a solution?

Maybe you are looking for

  • Any Ideas on a how to falling snow?

    I have a image that I would like to make a little snow falling over it. As a amateur rookie at flash, I'm looking for a tutorial or some generous genius to explain how a dummy could do it? thks

  • How can I stop iPhoto from showing Events?

    HI Folks, I've used iPhoto for a long time, and I am just completely frustrated at the existence of "Events." Every single time I take a photo and import it, I get a new event. Even worse, I have hundreds of unnamed "Events" because that method of or

  • Unable to create table with column default value with date interval

    Please help to create table with calculated date defaullt value: CREATE TABLE emp (   birth_date  DATE  DEFAULT sysdate + interval '3' day NOT NULL or CREATE TABLE emp (   some_date DATE,   birth_date  DATE  DEFAULT some_date NOT NULL or CREATE TABLE

  • Power button flashes three times in regular intervals!

    Everything works fine but the power button on my cinema display flashes three times in regular intervals over and over again. I'm going to have a seizure!

  • What is the correct way to measure RPM using Visual Basic?

    I have something that works now, but I want to know if there is a better way. I am using a 6023E, I have a Hall Effect switch that goes low then high each rev when a magnet goes by. I have the signal connected to the GATE pin on counter0. I poll the