MATLAB: How to find derivative of CSV data plot

csvderivative

I have a csv file with uniform points but i would like to write MATLAB code for obtain the derivative of the plotted function(unknown) with time. How can i do this?
if true
% code
end

Best Answer

It is easiest to use the gradient (link) function:
[D,S,R] = xlsread('Uniform_points.csv');
t = D(:,1);
f = D(:,2);
dt = mean(diff(t));
df = gradient(f,dt);
figure
subplot(2,1,1)
plot(t, f)
grid
title(S{2},'Interpreter','none')
xlabel(S{1})
subplot(2,1,2)
plot(t, df)
grid
title(['d(',S{2},')/dt'],'Interpreter','none')
xlabel(S{1})