cubic spline function
조회 수: 6 (최근 30일)
이전 댓글 표시
Hi,
I am having trouble using the Cubic Spline function.
I have to find the max value for y and what it corrospondes to in x. The data that has been given is
x = [0.6,0.7,0,8,0,9,1.0,1.1,1.2,1.3,1.4]';
y = [107,110,112,113.5,114,112,109,104,97]';
I have then used the follow code becuase I want to know the maximun y and what it corrospondes to x
yi = interp1(x, y,0.6:0.01:1.4,'spline')'
Now looking though the variable editor screen in Matlab I can see that 114.0904 is the max value but I am not sure how to extract this using matlab. The code I have been using is below.
x = [0.6,0.7,0,8,0,9,1.0,1.1,1.2,1.3,1.4]';
y = [107,110,112,113.5,114,112,109,104,97]';
yi = interp1(x, y,0.6:0.01:1.4,'spline')'
y1=(0.6:0.01:1.4)';
ans = max(yi)
Now this gives me the answer 114.0904 but now I am not sure for what value of x this is?
Any help would be appriciated
Thanks
댓글 수: 0
답변 (1개)
Andrei Bobrov
2011년 9월 18일
use functions from Curve Fitting Toolbox
x = [0.6,0.7,0.8,0.9,1.0,1.1,1.2,1.3,1.4]';
y = [107,110,112,113.5,114,112,109,104,97]';
pp = interp1(x,y,'spline','pp');
dpp = fnder(pp);
maxy = fnval(pp,fzero(@(k)fnval(dpp,k),mean(x)));
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!