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: 

Calculating custom derivative

Solved!
Go to solution

Hi everyone,

 

I would like to calculate a custom derivative (two-point derivative to be precise) of my data. The two-point derivative means that df(x)/dx = [f(x+h)-f(x-h)]/2h, rather than df(x)/dx = [f(x)-f(x-h)]/h. I am a Labview beginner and have no idea what is the best way of handling this, but I suspect that using a loop with a formula node where the data is being fed via shift registers would be the way to go.

 

Currently, I have my data generated as two 1D arrays (voltage & current) that are converted to a 1D array of cluster of 2 elements and plotted on a graph. Having another graph that shows the two-point derivative would be very useful.

 

Thank you in advance for any help with his.

0 Kudos
Message 1 of 8
(3,742 Views)

Do you want h arbitrarily small or just use your array of data where h is plus or minus one index position? You also need to decide what to do at the ends.

 

In both scenarios, this seems like a pretty trivial problem. Can you attach a small VI that contains a typical dataset as diagram constant?

 

I am sure you don't need a formula node or even shift registers. Be aware that taking the derivative oftern requires additional filtering if the original data is noisy.

0 Kudos
Message 2 of 8
(3,714 Views)
Solution
Accepted by topic author PiotrW

Here is an implementation using the data points. It accepts non-uniformly spaced data.

 

Lynn

Message 3 of 8
(3,702 Views)

Often voltage vs. current curves can be modeled and fitted to a nonlinear model having only a few parameters. Once you have the model parameters, graphing the derivative is trivial.

0 Kudos
Message 4 of 8
(3,695 Views)

Lynn:

Thank you very much for that VI! I'm pretty sure I can apply this sub-vi to my main vi. Much appreciated.

 

Altenbach:

For h, I would just use the data from one the first array (voltage). 

 

The data is pretty clean when it comes to noise. I have previously done the two-point derivative in Origin Lab and it looked fine.

 

What do you mean about a dataset diagram constant? I cannot take a measurement at the moment, but have attached a screenshot of the part of the VI where data is being saved as arrays. I basically need to calculate the two-point derivative of IDS with respect to VGS. Apologies if this doesn't answer your question.

0 Kudos
Message 5 of 8
(3,693 Views)

PiotrW wrote:

What do you mean about a dataset diagram constant?


After you take a measurement and the raw data is in the xy graph, stop the program, open the block diagram, right-click the terminal of the graph, and select "create constant". Copy this constant to a new VI, save and attach it here.

0 Kudos
Message 6 of 8
(3,688 Views)

Thank you, I know what you mean now. When opened in Excel, the data that goes into the graph is in the form of two columns per each curve on the graph, e.g. column 1 is the x-axis data for curve 1, column 2 is the y-axis data for curve 1, etc.

 

I do not have such a datafile at the moment, because the graph is empty and I cannot take a measurement at the moment. Apologies.

0 Kudos
Message 7 of 8
(3,678 Views)

Lynn: I've tried your solution using one of my previously measured sets of data and it worked very well, except one thing. In the last loop, I had to change one of the plus signs to a minus sign, otherwise I wouldn't be getting 2h for the denominator in the derivative (see attached).

 

Anyway, thank you very much!

0 Kudos
Message 8 of 8
(3,655 Views)