LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array comparison - return element with larger amplitude

Highlighted

Hi all,

I have an array that I acquired from Peak Detection that returns all elements above a threshold. I have pretty good results but (because of some noise) I have some indexes that I want to remove because they are too close together. I want the peaks to be separated by at least 200 samples. I tried using a for loop by comparing points within 200 samples and return the higher amplitude but, since I'm very new to Labview, I can't seem to figure out how to make this work. I hope this makes sense. 

 

Regards,

Chris

0 Kudos
Message 1 of 8
(661 Views)

Attach your VI.  Many students and others "very new to LabVIEW" use this Forum, and some of us enjoy teaching, so will suggest how to "fix what is broken" and help you to learn.

 

Bob Schor

0 Kudos
Message 2 of 8
(618 Views)

Thanks Bob,

Here's my VIs and sample files for testing. I might also mention they're not elegant by any means. I tried commenting to help you through it. 

0 Kudos
Message 3 of 8
(612 Views)

Hi Chris,

 

I want the peaks to be separated by at least 200 samples.

Which peak do you wnat to keep for result?

The first within 200 samples? The last? The average?

 

I tried using a for loop

That's ok.

Compare current peak position with last position to determine their distance. When distance < limit then keep the correct peak of both… (Hint: You will need a shift register in the loop.)

 

To give an idea:

check.png

 

Comments on your last post:

  • you would ease our lives when you would attach all those files within a ZIP file: just one click for download instead of 6!
  • You should indicate the LabVIEW version you are using. It's kind of annoying when someone will download your VIs just to find them "too new" for the LabVIEW version he/she has available…
Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

Message 4 of 8
(592 Views)

Hi Gerd,

 

It was late and I didn't even think of a zip Smiley LOL I'll be sure to do that in future posts. If I'm using Labview 2017, would I just say v17 on the zip file? As for which peak I want to keep, the one with the highest amplitude. I assume I would bring that amplitude array into the for loop and do some comparison? Last, you use a constant on the shift register, is that function similar to a count?

0 Kudos
Message 5 of 8
(570 Views)

Hi Chris,

 

you use a constant on the shift register, is that function similar to a count?

Yes.

Smiley Very Happy

Best regards,
GerdW
CLAD expired, using 2009SP1 + LV2011SP1 + LV2017 (+LV2018 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 6 of 8
(562 Views)

@SteampunkMenace wrote:

If I'm using Labview 2017, would I just say v17 on the zip file? I recommend saying "I'm using LabVIEW 2017" as the final line in your post -- pretty unambiguous.

As for which peak I want to keep, the one with the highest amplitude. I assume I would bring that amplitude array into the for loop and do some comparison?  If you create a cluster of "Peak" and "Peak Index" and output an array of these clusters, you could simply use the Array Max/Min function and use the Peak Index value.

 Last, you use a constant on the shift register, is that function similar to a count?  It is an "initialization", set so the initial time through the loop you have something from the "previous" loop, not an "unexpected default value".


Bob Schor

Message 7 of 8
(559 Views)

Thank y'all for the feedback. I'm learning a bit more each day and it makes sense to cluster the arrays. I'll keep working at it with this info.

 

Regards,

Chris

0 Kudos
Message 8 of 8
(551 Views)