From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Detection of multiple plateaus of different lengths

Solved!
Go to solution

Hi,

can anyone help me detect the plateaus in this signal (beginning and end locations)?

 

0 Kudos
Message 1 of 11
(3,831 Views)

Hi Sarah,

 

please define "plateau" for your data!

I see a rising ramp with some noise (peaks) added…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(3,826 Views)

Hi GerdW,

I'm not sure if the naming is correct. Please see the figure.

Thanks

0 Kudos
Message 3 of 11
(3,820 Views)

Hi Sarah,

 

so you want to find subsets in your array where consecutive elements have the same value?

 

Use a loop and compare current element with previous one: if they are the same you have found a "plateau"…

Result of this very simplistic approach:

check.png

Plateaus marked with red plot…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(3,818 Views)

Hi GerdW,

thanks for ur reply.

No, the subsets don't contain same values (check the circles in the figure in my last post). The values in each step (plateau) are also containing noise. They are below or under a mean value. I have an overall standard deviation for these values, so i can define a % of variation between the values at each step.
So I want to detect this kind of steps, and measure its length.

I also have the problem that the signal is rising. So I cannot define a threshold, like for a normal squared signal. If it is so, then I can detect and measure the length of the each "step" array using two loops.

I hope I could explain my problem.

0 Kudos
Message 5 of 11
(3,794 Views)

Hi Sarah,

 

The values in each step (plateau) are also containing noise. They are below or under a mean value. I have an overall standard deviation for these values, so i can define a % of variation between the values at each step.

Then you don't need to compare for being equal, but you need to check for being within a certain range… (When it comes to ranges you should immediatly think InRangeAndCoerce!)

 

I also have the problem that the signal is rising.

You might remove this "rising" by subtracting a variable offset…

Determine the rise rate (aka gradient) from your data and use it to level out the curve!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 11
(3,790 Views)

One other way to look for the plateaus would be a slope change. It looks like most of the plateaus are flat so you could look for a slope value within a certain range or below some set point.

Tim
GHSP
0 Kudos
Message 7 of 11
(3,787 Views)

Something like this. I ran the data and it seemed to find all of the plateaus and the lengths.

Tim
GHSP
Message 8 of 11
(3,777 Views)
Solution
Accepted by topic author s.steen

You can do this in a way that doesn't require looking at each sample using a FOR loop, which will probably be faster if you have a lot of data.

 

By applying a criteria to the point-to-point slope data to turn it into a Boolean array you can use "search 1D array" to find the indexes where the answer to "is plateau?" question changes.  The indexes are related to the timestamp by the sample rate so you turn indexes into time by simple multiplication.  

Message 9 of 11
(3,757 Views)

Thanks to Tim, Zwired1 and GerdW
@ GerdW: subtracting a variable offset won't work for each signal that I have. In some cases it may sink and then rise because of any interference or other disturbances. Defining this would be too complicated (for me) for this purpose I think. So the slope can be used for this purpose, plus using InRange and Coerce (thanks for the hint)
@Zwired:

I tried ur code, but I needed to define more criterias so that it works properly. Thank you that u shared the screenshot.

@Tim

ur code works best for my present data that I become at the moment. Thank you very much for posting the code!!

0 Kudos
Message 10 of 11
(3,730 Views)