Hi I am looking to calculate and plot the fourth derivtative of a reflectance plot for coral spectra - commonly done in papers by the savistky and golay, 1964 method.
I have used the smoothing function on my coral mean spectra (x3) (1st image)
S2 = smooth(S1);
Then went to take my 1st derivative (2nd image)
This turned out ok using this coding:
dy = diff(S2)/diff(wv1);
But I believe this is the wrong method for taking the derivative of the reflectance spectra as I loose data going fromm 1446x1 to 1445x1 each time i derive i.e.
taking the second derivative like so:
d2ydx2 = diff(dy)./diff(wv1);
producing a graph like image 3 - which when it comes to the 4th i have lost nearly all the data (image 4)
Does anyone know where I am going wrong, as this must be much more straight forward given it has been used so frequently.