How to integrate a vector after derivating it to interpretate original values?

Dear colleagues,
I work with spectral signals, which are vectors composed by numeric values. These signals are better interpreted when derivated, and I do it using savgol from PLS toolbox or sgolayfilt, normally using first derivative and 2nd order polynomial. Nonetheless, after performing the data treatments, I would like to return to the original values, but I am failing when trying it. My vectors are composed of 110 variables (columns), and all the examples I can find suggests the use of integral to solve functions problems... As an answer, I need the vector (with my 110 variables) back so I can better interpret what is going on with the signal.
I have already tryed:
x = int (vector); --> fail
x = int (vector,1,110); --> fail
x = trapz (vector); --> fail
x = trapz (vector,1,110); --> fail
x = cumtrapz (vector); --> fail
x = cumtrapz (vector,1,110); --> fail
So, please, I would like to kindly ask you guys if someone here can help me, please.
My sincere thanks in advance!
Best regards,

2 Comments

As an answer, I need the vector (with my 110 variables) back so I can better interpret what is going on with the signal.
The question is: Why is the original vector gone ? Did you forget to save it ?
Hi Torsten,
Thanks for asking,
Actually, I need to derivate signals from absorbance (spectroscopy) to find where one signal differs from other ones regarding the slopes. So, I deconvolute it using multivariate curve resolution and then I have the resolved curves, but they are signals which are derivatives. What I would like to have are these resolved signals looking like absorbance information, and I am failing in doing it. The advantage of having the signals as absorbance (so, I would need to transform it back) is to show where the signals are increasing or decreasing in intensity (for example), and so conclude the chemical transformations.
Do you think I can do it?
Thanks again!

Sign in to comment.

 Accepted Answer

You should use cumtrapz(), but be sure to pass in the sample period (regularly spaced signals) or the vector of times (irregularly spaced).
Also, when you took the derivative you lost the constant offset, so you need to add that back in. But determining the proper offset can be tricky since you are reconstructing a smoothed signal. You might want to calculate mean() of the reconstructed signal minus mean of the original and add that back... but not if you did trend removal...

3 Comments

Thanks for answering
Indeed, I have tried it but maybe I am doing some mistakes because it is failing:
x = cumtrapz (vector); --> fail
x = cumtrapz (vector,1,110); --> fail
Please, if you have any trick to help me on this, I am very grateful because all my tries are failing.
Many thanks in advance
x = cumtrapz(SPACING, vector, dimension)
You indicated that "My vectors are composed of 110 variables (columns)"
However, you should not be integrating over different variables: you should only be integrating within one variable. You should be using a 2D array, with rows corresponding to time, and columns corresponding to variable, and dimension would be 1 to integrate over individual variables. SPACING could be a scalar value if all of the variables have the same sample rate, but otherwise it should be a vector of 110 values indicating the individual sampling rates.
Thanks Walter,
I am sorry for my delay on anwering you, but I'll try it this weekend and I'll give you a feedback regarding this issue.
Thank you a lot!

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!