LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calculate dV/dI where I and are 2 vectors results of measurement

I need to calculate the vector dV/dI(I) where I and V are 2 results vectors from electrical measurement system. dose it exist a VI tools to do that?
0 Kudos
Message 1 of 9
(4,166 Views)
I am attaching a VI that will take a vector X and a Vector Y and compute DY/DX. Be careful at the endpoints and make sure you give values for points -1 and N+1 boundaries. I didn't add error checking for dx = 0 cases. Also included is a simple example for calling the function.

Marc
Download All
Message 2 of 9
(4,170 Views)
Thanks for this VI, Jeff.

I want to point out a few caveats with this VI for any future people who stumble across it (as I did). This is a forward looking derivative only. This means that the derivative values most closesly correspond to the positions X[-0.5], X[0.5], X[1.5] and so on, where the half value index represents the linearly interpolated X value between two points on in the array. (Surely there is a more succinct way of saying this.  Sorry.) For example, if the X values were 2,4,6..., the X values for dY/dX would be 1,3,5, and so on.


Also, I believe that the final condition is never used. If you look at the code, it should get used in the case where the While loop iteration i is greater than or equal to the array length, N. That never happens as i's maximum value is N-1.
0 Kudos
Message 3 of 9
(4,105 Views)
Check out this thread for a discussion of derivatives in LabVIEW.

http://forums.ni.com/ni/board/message?board.id=170&message.id=102065#M10206

The take-home message is that Savitzky-Golay is the way to go.  You can find details of this algorithm in the second edition of the Numerical Recipes books by Press et. al.
Message 4 of 9
(4,092 Views)
Thanks for the tip, about Savitzy-Golay.

My current application is quite noise-free (amazingly) so I implemented a weighted central difference algorithm which I am attaching for the forum's feedback. I'd like feedback on the validity of the weighting scheme, which is pretty straightforward. I figure this algorithm already has someone's name attached to it, or may be so simple that it didn't even get a name! However, before I submit this to the EPD it'd be nice to have someone with more numerical experience than I give it a thumbs up.

Basically, the derivative is a central difference but the forward and reverse differences are averaged with a weighting factor based on the inverse of the distance to the center.  If dx+ is the distance from the point in operation to the next point, and dx- is that distance to the previous point, then

w+ = (1/dx+) /(1/dx+ + 1/dx-) = 1/(1 + dx+/dx-) .

Likewise for w-.

Thanks,
Jason
Message 5 of 9
(4,085 Views)

Hi Jason,

 

I've only used your VI briefly but it seems to work correctly.

 

I'm not too sure what the basis is for you weighting scheme.  Might you explain?  Why did you implement the weighting?  To compute initial and final conditions?  Is there some theory which explains in more detail?

 

Anyway, thanks for the VI.

 

Battler.

0 Kudos
Message 6 of 9
(3,639 Views)

It appears that the Savitzky-Golay 2nd derivative operation is discontinuous at the start and end points.

 

How do you get around this?

 

Thusfar I've had success with the VI posted by Jason.

0 Kudos
Message 7 of 9
(3,637 Views)

Savitzky-Golay is computationally equivalent to taking the least squares fit to a polynomial over a restricted set of data, picking a point on the calculated curve, then returning its value/derivative/second derivative...  For example, you can pick a data interval of seven points and a position equivalent to the center point (point 3 or 4, depending on whether you like zero or one based arrays).  If you do this, the first point of valid data you will get is the fourth point, since you need three earlier points to run the curve fit.  Similarly, there is no valid data for the last three points, either.  This is normal for convolution filters.  You have two basic options:

  1. Take extra data on the ends.  This is common when you are collecting data from a physical source, since it is very easy to implement.
  2. Use different Savitzky-Golay coefficients for the six end points so that the position of interest is over the point of interest, not the center point.  This can take you all the way to the edges, at the cost of more computation.  See the reference above for details of the Savitzky-Golay calculation.

To get second derivatives, you need to have at least three points in your filter, and should really have five or more if you have noise issues.  This is why the second derivative gives "errors" on the end points.

 

Note that Savitzky-Golay is now native in LabVIEW.  This is a very old thread.  In the future, you may get better response by starting a new on.  Jason's last post was almost two years ago.

0 Kudos
Message 8 of 9
(3,623 Views)

Savitzky-Golay is computationally equivalent to taking the least squares fit to a polynomial over a restricted set of data, picking a point on the calculated curve, then returning its value/derivative/second derivative...  For example, you can pick a data interval of seven points and a position equivalent to the center point (point 3 or 4, depending on whether you like zero or one based arrays).  If you do this, the first point of valid data you will get is the fourth point, since you need three earlier points to run the curve fit.  Similarly, there is no valid data for the last three points, either.  This is normal for convolution filters.  You have two basic options:

  1. Take extra data on the ends.  This is common when you are collecting data from a physical source, since it is very easy to implement.
  2. Use different Savitzky-Golay coefficients for the six end points so that the position of interest is over the point of interest, not the center point.  This can take you all the way to the edges, at the cost of more computation.  See the reference above for details of the Savitzky-Golay calculation.

To get second derivatives, you need to have at least three points in your filter, and should really have five or more if you have noise issues.  This is why the second derivative gives "errors" on the end points.

 

Note that Savitzky-Golay is now native in LabVIEW.  This is a very old thread.  In the future, you may get better response by starting a new on.  Jason's last post was almost two years ago.

0 Kudos
Message 9 of 9
(3,621 Views)