LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to fit a step function

Solved!
Go to solution

Hi,

I have a 1D binary array. How am I supposed to fit it to a step function?

Attached is the waveform of the array.

Many thanks

0 Kudos
Message 1 of 9
(4,444 Views)

Define a Step Function (so we know precisely what you mean).  Note that you've shown something that is 0 up to some time, then is 1 for some time, then 0, then 1, etc.  This can be constructed by a series of Step functions (where my definition is a function, Step(t, t0), that is 0 for t<t0, and is 1 for t>= t0).  To get a pulse that goes up at t1 and down at t2, just add Step(t, t1) to -Step(t, t2).  To get the next pulse, add Step(t, t3) - Step(t, t4), and so on.

 

For a Binary Array, the index of the Array elements is "t", True is 1, False is 0.

 

Bob Schor

Message 2 of 9
(4,409 Views)

The problem with step functions is that the partial derivatives with respect to the "x-shift" parameter will not work, because x is quantized to the measurements positions and shifting by a fractional value of less than the point spacing will no change the chisquare.

 

Please attach some typical data. Since your data is binary, all you can get out of it are the indices if the T>F and F>T positions. Is that what you want?

0 Kudos
Message 3 of 9
(4,405 Views)

Dear Bob,

Thanks for your answer. What you are saying is that I generate a function that fits the data (correct me if I'm wrong). But what I'm looking for is that the computer can give me the intervals (of time in our case) where y values are 1. Is it possible to do that?

Rosh

0 Kudos
Message 4 of 9
(4,400 Views)

@Rosh_Liu wrote:

Is it possible to do that?


Yes, it is possible. What have you tried?

Do you want the duty cycle?

0 Kudos
Message 5 of 9
(4,394 Views)

I have tried the search all indices for a value in 1D array. But I would love know about your thoughts on the duty cycle since it feels right. Thanks very much!

0 Kudos
Message 6 of 9
(4,386 Views)

Since you are graphing (0,1) and not booleans, all you need is to sum all array elements and divide by the array size. This will give you the fraction of TRUE elements. Make sure that your datatype is sufficient to hold the sum (e.g. use I32)

Message 7 of 9
(4,380 Views)

Thanks very much. I won't mark it as solution since I kinda asked the questions weirdly that the discussions didn't answer the question. But anway, problem solved!

0 Kudos
Message 8 of 9
(4,373 Views)
Solution
Accepted by topic author Rosh_Liu

Of course there are infinitely more parameters that could be extracted from the data, e.g. the average pulse spacing, pulse width, jitter in spacing and width, etc.

For the duty cycle mentioned earlier, you should also trim the data e.g. at the rising edges of the last and first pulse, else the result could be slightly off.

0 Kudos
Message 9 of 9
(4,371 Views)