09-02-2013 04:14 PM
I have not tried it but the detailed help file for the Savitsky-Golay FIlter Coefficients VI shows a block diagram where it processes the first and last k points separately and then uses Build Array to recombine everything for smoothing. It does not say whether that will work for differentiation.
My VI uses mostly the Differentiation code with the central part of the smoothing code.
Lynn
09-02-2013 04:42 PM
Maybe i didnt understand your reply, but is there any possibility to get a plot without any cuts. I mean, when i choose some number of side points, S-G VI cuts that number of samples from the begining and the end . I am too newbie to figure it out
09-02-2013 06:02 PM
The basic concept of S-G is that it fits a polynomial to each central point in the data set and k side points on either side of that point. It then calculates the smoothed and derivative values from the polynomial. So, any attempt to calculate derivatives of the first or last k points in the data set need to use some other approximation. The estimate of the derivative will be worse at the edges simply because less data is used.
Because the values of the derivative at the beginning and end of the dataset would be less accurate, perhaps you could think about other options. Right now you are losing 480 out of 10000 points. If you acquire 10480 points you could get good derivative calculations on 10000 points. Or acquire data continuously and process it in overlapping segments so that the endpoints can be discarded.
I looked at the section in Numerical Recipes on derivatives. All the techniques discussed require processing of multiple points of the data.
Think about it this way: When you have a finite data set, it probably represents a segment of the data measured from some continuous or ongoing process. The act of extracting a segment of the continuous data is the same as multiplying the continuous signal by a square pulse. The derivative of the product of two functions includes information about both functions. The derivative of the square pulse is two impulses, one at each edge. You can see that the derivatives of a "chopped off" real data set will have some hard to define regions at the edges.
What will you be doing with the derivatives after you calculate them? Do you have a mathematical model of the process which generates the data?
Lynn
09-03-2013 01:56 AM
Johnsold,
I had a look at your vis and one question came up:
Where is dt handled? Different samplerates should give different amplitudes in the derivate.
09-03-2013 04:04 AM
Thx for comprehensive reply. I have no mathematical formula to make my signal more sampled. Next time i will try to aquire more samples then, for now, i can copy from my data(excel) additional 240 samples to the beggining and end(should do not like this but the difference between real measurement and copied datas will probably be like 1:10000).
I am trying to obtain resistive current by combining some formulas. To do it, i need to mix some integrals and that 1 unlucky:) derivativeof Voltage and Current signal. My another, hope last problem is to make FFT of resistive current, cant handle with that. I ve used some FFT VIs but everytime plot is empty.
Ive attached my project and settings inside. Remember to set sidepoints to 240!.
I would appreciate if someone of u guys could take a look on it.
09-03-2013 09:07 AM
Henrik,
You are right. The number dialed is imaginary. The S-G filter algorithm is based on the number of sample points and does not take into account the physical meaning of the sample interval. Proper amplitude scaling of the derivative needs to account for the magnitude of dt. The shape should be correct. Thank you for pointing this out.
menomena,
The reason you get no output from the FFT is that you have NaN values at the end of the Resistive Current array from indexes 9760 to 10239. When you do the Array Subset you need to remove side points elements from each end, not just the beginning. In the VI I posted you can see that I used Side Points as the index value and Length of the Array - 2*Side Points as the length of the subset. When I do that for your VI, I get no NaN values and can do the FFT.
Lynn
09-03-2013 10:09 AM
Thank you so much, FFT works
09-04-2013 03:53 AM - edited 09-04-2013 03:56 AM
Here is a SG diff that should scale correctly , keep in mind:
It will shorten the wfrm length one sidepoint length (to get a correct phase)
At the beginning you will have filter artifacts. To avoid them cut 4 times the sidepoint length
NOT FINALLY TESTED...
and to use it with continous wfrm blocks the recalculation of the filter values could be avoided 😉
test vi
07-21-2017 04:45 AM
Pay attention that in your vi you cut 4 times ORDER points instead of 4 times SIDEPOINTS points.
In any case, nice job!
07-21-2017 06:48 AM
Your rigth 🙂
the Q&D test routine used the order instead of sidepoints as noted