I have the following arbitrary data:
t=[0 1 2 3 4 5 6 7 8 9 10 12 14];
C=[0 1 5 8 10 8 6 4 3.0 2.2 1.5 0.6 0];
area=trapz(t,C);
E=C./area;
F=cumtrapz(t,E);
When plotted, it looks as follows:
Now, I want to smoothen the plots:
t_int=[];
E_int=[];
F_int=[];
xmin=min(t);
xmax=max(t);
points=5000;
stepSize=(xmax-xmin)/points;
for i=xmin:stepSize:xmax
t_int=[t_int i];
E_int=[E_int interp1(t, E, i,'pchip')];
F_int=[F_int interp1(t, F, i,'pchip')];
end
Okay, so here we get to the actual part where the problem is. In reality, I have some F plot and I would like to get its corresponding E plot. Since the F plot is the integral of E, E is the differentiated F plot.
So then:
dy=diff(F_int);
dx=diff(t_int);
dydx = dy./dx;
plot(t_int(:,1:length(dydx)),dydx,t_int,E_int)
legend('E (calculated)','E (actual)')
Why is the calculated E plot so wonky?