How can I find the where the second derivative is zero?
5 views (last 30 days)
Show older comments
I tried using the fzero function to solve for the root after graphing, but can't seem to get it:
>> z=[0:0.5:3];
>> T=[70 70 55 22 13 10 10];
>> plot(z,T, 'o')
>> A = spline(z,T);
>> M = diag(3:-1:1,1);
>> %first derivative
>> D=A;
>> D.coefs = D.coefs*M;
>> %second derivative
>> D1=D;
>> D1.coefs = D1.coefs*M;
>> x = linspace(z(1),z(end),1001);
>> plot(z,T,'x')
>> hold on
>> plot(x,ppval(A,x),'r')
>> plot(x,ppval(D,x),'g')
>> plot(x,ppval(D1,x),'k')
>> legend({'Original Data','Spline','First Derivative','Second Derivative'})
3 Comments
Randy Souza
on 5 Apr 2013
I have restored the original text of this question.
Me Yu, this question has an accepted answer, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.
Accepted Answer
Matt J
on 29 Mar 2013
Not sure what the problem is. The roots I get all seem to agree with your graph
>> fzero(@(x) ppval(D1,x),0)
ans =
0.1175
>> fzero(@(x) ppval(D1,x),1)
ans =
1.2162
>> fzero(@(x) ppval(D1,x),2)
ans =
1.9680
>> fzero(@(x) ppval(D1,x),2.4)
ans =
2.2544
11 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!