Jump to content

Working with an Array


Recommended Posts

Can someone please help.

Basically I was given data for a waveform graph(with two waveforms), from which I was able to extract two 1D arrays using

"index array".One of the waveforms create a square wave with one pulse with a leading edge and lagging edge. I was wondering how can I find the index of the leading edge of this array. I dont want anyone to do the work for me, but just pointers on how to go about.

Thanks!

Link to comment

QUOTE (cheekychops @ Apr 30 2008, 05:29 AM)

One of the waveforms create a square wave with one pulse with a leading edge and lagging edge. I was wondering how can I find the index of the leading edge of this array.

Check out "Threshold 1D Array" in the "Array" functions palette.

Link to comment

I did this a long time ago and for some reason I couldn't use the Threshold Array primitive. It may have been improved now and work as desired so you should try it.

However, I am thinking it doesn't manage the leading AND trailing edges well. Also, it is possible, if there is enough noise that is faster than the rise and fall, that it will to mess you up (this is not likely). In that case you need to do a running average around each point.

I do remember that I used a scheme that subtracted adjacent points from each other and checked the absolute value of this difference to see if it exceeded a threshold. If they difference was negative (1st point greater than the 2nd) then you know it is the trailing edge.

So you have a shift register that saves that last point processed by the for loop. On the 2nd and subsequent iterations you get the difference between the earlier and the currently indexed point, and test it for exceeding the threshold, and for the trailing or rising quality, then you build an array of the for loop counts factoring in the scan rate for the acquiaition to get an elapsed time. You can subtract leading and trailing elapsed times to get pulse width if that interests you.

Just in case your waveform is not in the time domain... In my own case I was not measuring time but angle of rotation by way of an encoder clocked acquisition. So I needed to know the angle between encoder (external trigger) pulses. If I had 247 of 7200 pulses from the start as the location of a signal edge, then I knew itindicated and elapsed angle of 247 x (360deg/rev x (rev/7200 pulses)) = 12.35degrees.

After writing all that, I think the Threshold Array business was clunky for me because I had a big interest in separating out the rising and falling events. So if you care about that you might want to use my method.

Mike

Link to comment

QUOTE (cheekychops @ Apr 30 2008, 04:43 PM)

...I need to find the exact index of the leading edge and exact index for the falling edge...

Maybe like this

1. A = your array

2. Check A greater than t, where t is a threshold value (i.e. use A > t), gives you a boolean result array B.

3. Search B for value of TRUE, this gives you the index of the leading edge.

4. Use the leading edge index as start index and search B for a value of FALSE, gives you the trailing edge index.

/J

Link to comment

Thanks /J worked :thumbup:

QUOTE (JFM @ Apr 30 2008, 05:37 PM)

Maybe like this

1. A = your array

2. Check A greater than t, where t is a threshold value (i.e. use A > t), gives you a boolean result array B.

3. Search B for value of TRUE, this gives you the index of the leading edge.

4. Use the leading edge index as start index and search B for a value of FALSE, gives you the trailing edge index.

/J

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.