How can I find the where the second derivative is zero?

5 views (last 30 days)
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
Jan
Jan on 2 Apr 2013
Deleting a question after an answer has been posted, is very unfriendly.
Randy Souza
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.

Sign in to comment.

Accepted Answer

Matt J
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
Matt J
Matt J on 1 Apr 2013
Hmmm. I can only assume you accidentally revised D somewhere. I get -73.0354
Me Yu
Me Yu on 1 Apr 2013
Edited: Me Yu on 1 Apr 2013
ok but that line of code is correct i just have to find a mistake with D?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!