For you to calculate the daily derivative you have to define a daily measurement for your variables. Normally the average is a good choice, you can then group the mean of each 288 values in a vector and only then use diff, otherwise you will have the derivative of every 5 minutes. As Stephan said, you have indeed many NaN values in your data, this may be a problem if you want to have the results for all days, but since there are still some valid data points, I wrote a code that takes the NaN in consideration.
Data = load('do_deriv.mat');
DoDailyBuffers = buffer(Data.DO,288);
IrradianceDailyBuffers = buffer(Data.irradiance,288);
DoDaily = nanmean(DoDailyBuffers);
IrradianceDaily = nanmean(IrradianceDailyBuffers);
DoDt = diff(DoDaily);
figure,
subplot(1,2,1)
plot(IrradianceDaily(2:end),DoDt,'*','linewidth',3)
grid on, set(gca,'fontsize',18)
xlabel('Irradiance (Daily Average)')
ylabel('Daily derivative of oxgyen')
subplot(1,2,2)
plot(IrradianceDaily,DoDaily,'*','linewidth',3)
grid on, set(gca,'fontsize',18)
xlabel('Irradiance (Daily Average)')
ylabel('Oxygen (Daily Average)')
The left graphic is what you asked, but in my opinion, to see if light drives the amount of oxygen, the right one could give you a better insight. There you direct see the relation between both variables which, in this case, looks somewhat linear. You can then verify the correlation coefficient between the data:
NotNaNIndex = ~isnan(DoDaily);
R = corrcoef(DoDaily(NotNaNIndex),IrradianceDaily(NotNaNIndex))
R =
1.0000 0.8462
0.8462 1.0000
0.8462 is a relatively high correlation coefficient, which could imply that oxygen increases with Irradiance.
Best Answer