How to differentiate a piecewise function?
显示 更早的评论
Hi to all. I have a piecewise function and I want to differentiate it but the derivative will not exist at endpoints. I tried to interpolate it such that the edges are more smooth and the derivative is continuous, but when I plot it, I still get the harsh edges. What to do now? This is my code:
t=0:60;
L =(15-t/2).*(t>=0 & t<=20)+...
(5).*(t>20 & t<=40 )+(-15+t/2).*(t>40 & t<=60 );
P=interp1(t,L,'pchip');
hold on
plot (t,P,'linewidth',4)
xlim([0 70])
ylim([0 20])
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
