# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Merge Chronologically two array from a chart graph

Hi all,

I am working on peak detection for an application.

Each peak has to increment a counter, each valley will decrease it.
The threshold is set at 200 for both valleys and peaks. If the counter goes to negative value, counter will be 0.

I used the peak detector.vi of labview.

The image represent the merge of three different element in the same graph:
- raw file

- peaks

- valleys

Is there a way to merge the peaks and valleys arrays only into one array in such a way to simplify the counter logic with a simple addition or subtraction?

From the attached image I expected that the counter will be 2.

Important is that the two array has to be merged in chronological order like in the image.

Thank you in advance for the support.

Message 1 of 6
(203 Views)

## Re: Merge Chronologically two array from a chart graph

Hi Mdr,

@Mdr20 wrote:

Each peak has to increment a counter, each valley will decrease it.
The threshold is set at 200 for both valleys and peaks.

Then why do you ignore the first valley? It's clearly below -200…

@Mdr20 wrote:

The image represent the merge of three different element in the same graph…

Did you know we cannot debug/edit/run images in LabVIEW? Especially images showing parts of frontpanels???

@Mdr20 wrote:

Is there a way to merge the peaks and valleys arrays only into one array in such a way to simplify the counter logic with a simple addition or subtraction?

Important is that the two array has to be merged in chronological order like in the image.

Probably there is a way!

When you know the position of each valley/peak then you can easily use that information to sort your data!

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO
Message 2 of 6
(166 Views)

## Re: Merge Chronologically two array from a chart graph

Hi GerdW,

Then why do you ignore the first valley? It's clearly below -200…

My bad, the threshold is +-200.

Did you know we cannot debug/edit/run images in LabVIEW? Especially images showing parts of frontpanels???

Here the block diagram of the peak and valley recognition + counter logic.

Probably there is a way!

When you know the position of each valley/peak then you can easily use that information to sort your data!

Indeed, I assumed it is possible but I have problem to merge the two amplitudes array with the locations chronologically.

Message 3 of 6
(138 Views)

## Re: Merge Chronologically two array from a chart graph

Hi Mdr,

@GerdW wrote:

Did you know we cannot debug/edit/run images in LabVIEW? Especially images showing parts of frontpanels???

It seems you don't understand what I was trying to say here: please attach code! Real code!

It also helps to set some default values to help us to examine your code...

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO
Message 4 of 6
(124 Views)
Solution
Accepted by topic author Mdr20

## Re: Merge Chronologically two array from a chart graph

Hi GerdW,

maybe you were not clear either 😀

Anyway, I solved it. Thanks anyway.

For those who had the same problem:

- Merge the two array with insert into array.vi

- In my case, Real part represent the location of the peak/valley.

- For loop with the index array will give as output the sorted array based on sorted pointers given by openG sort array.vi

Message 5 of 6
(115 Views)

## Re: Merge Chronologically two array from a chart graph

Hi Mdr,

@Mdr20 wrote:

- Merge the two array with insert into array.vi

- In my case, Real part represent the location of the peak/valley.

- For loop with the index array will give as output the sorted array based on sorted pointers given by openG sort array.vi

• Why do you use InsertIntoArray when you want to build an array from two inputs? There's a BuildArray function!
• No need for OpenG, ArraySort can also sort your data (after creating an array of clusters from it).
• Use an autoindexing loop to get your sorted data arrays…

Best regards,
GerdW

using LV2016/2019/2021 on Win10/11+cRIO
Message 6 of 6
(85 Views)