Second Derivative using diff
Show older comments
I have a quick question concerning second derivatives using the diff function.
So, after I put in my x and y arrays I did
y1=diff(y)./diff(x)
I know that I have to change the length of y1 to take the second derivative. But I'm not sure in which order it should go. Should it be:
y1=[0 y1]
or
y1=[y1 0]
Then I would proceed to do
y2=diff(y1)./diff(x)
Any help is greatly appreciated! Thank you!
1 Comment
Victor Quezada
on 19 May 2020
Hi,
I'm coming from the future (from the coronavirus-age, actually). Sorry for being late.
Try: (just a suggestion)
diff(diff(y)./diff(x))./diff(x(1:length(x)-1))
or
diff(diff(y)./diff(x))./diff(x(2:length(x)))
Ciao.
Accepted Answer
More Answers (1)
Sanskruti Sawant
on 30 Jan 2018
0 votes
1/x
Categories
Find more on Variables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!