Double integration of principal componant

Hi,
I'm work in FTIR signal processing.
I would like to make double integration of principal components (PC) calculated on 2nd derivative of spectra to obtain something looking like spectra.
I use cumtrapz function but there is some problems...
When I use cumtrapz one time on PC based on first derivative spectra, the result seems to be ok. But when I use cumtrapz two time on PC based on second derivative, result are like if cumtrapz add a ax+b function (different depending on th PC) to the result I want. So the resulting "spectra" present a strong deviation(once again, different for each PCs)...
"Trapz" function doesn't works at all...
How to solve this problem? I'm nearly desperate...I hope someone could help me.
Best regards,
TRAVO Adrian
PS: I'm a MATLAB noob, and as a biologist, mathematics is a nightmare for me.
PS2: sorry for my poor english skill, hope my message is understandable.

Answers (2)

This is not surprising. cumtrapz is approximating an integral. int(f''(x)) = f'(x) + c1 where c1 is an arbitrary constant. int(int(f''(x)) = int(f'(x)+c1) = f(x) + c1*x + c2 where c1 and c2 are arbitrary constants. If you take f(x) + c1*x + c2 for any arbitrary finite constants c1 and c2 and take the second derivative, then you will get f''(x). This means that if your first cumtrapz() turns out to be off by a constant, then when you do the second cumtrapz() the result can be off by a linear amount a*x+b .
Thank you Walter :)
If I well understand (and I'm not sure), you explained me the source of my problem.
But can I solve this problem with matlab? How to find c1 and c2? I search in cumtrapz code, but I don't find... The only thing I know is that c1 and/or C2 seems to be added in the following line:
z = [zeros(1,n,class(y)); sum(dt .* (y(1:m-1,:) + y(2:m,:)),1)];
In all case, thank again for your answer :)
PS: I'm not sure of what "turns out to be off" means...

Asked:

on 30 Mar 2011

Community Treasure Hunt

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

Start Hunting!