11-11-2013 02:35 PM
Hi,
I have some data that looks like this
In the first part, (Indicated by the blue lines), I want to set it as baseline and set that to zero. But I want to do it automatically. Meaning, I don't want to click at two points and set that average value as baseline. I want the program to detect the baseline, find an average and then subtract it.
Also, it is not always the same amount of length that is there to detect as baseline. It might have smaller length than this example.
Can anyone help me with this please. I am using LV-2010.
I am also attaching this data in case somebody wants to play with it.
11-11-2013 03:18 PM
the attached VI thresholds your data and looks for the first point >2. It takes the index of that data point and multiplies it by 10% and 80% to arrive at the start and end point of the "should be zero" portion of the curve (what you identified with blue lines in your picture). It takes the mean of this portion of the curve and subtracts it from all of the Y values.
Caveats: the method is not robust to widely varying slopes in the region of interest (e.g. if you have a case where it is much slower to pass through "2") or if your DC offset is such that "2" is much later in your data than your intended "should be zero" portion.
Another way to do this is to threshold the derivitive of the data to look for the start of the "real" data. That takes the DC offset issue out of it, at least.
Note: there is a reverse 1D array operation in the VI 'cause the data was presented in time-descending order.
11-11-2013 05:42 PM
Hi Zwired1,
Can you please post your vi in LV-2010 or older version. I can not open your vi.
Thanks for your reply.
11-11-2013 06:23 PM
Good thing you couldn't open it -- there was a silly bug (I subtracted the mean from the x values, not Y).
Corrected and re-saved attached.