Save cubic spline coefficients to use as response in regression
이전 댓글 표시
Hi community,
I have two vectors and I would like to fit a cubic spline to:
y=[18.93000031 19.42000008 19.51000023 19.67000008 19.68000031 19.71999931];
x=[58.61111111 67.32055556 70.56194444 74.22694444 78.39388889 85.11555556];
I would also like to save the parameters of the fit at every point to use in regression analysis as my response (I want to change other variables at the points where I take a measurement in an experimental design.) How can I do this. I've not a very advanced matlab user but I hope this is an easier question for a pro in the community to answer.
댓글 수: 3
John D'Errico
2015년 2월 24일
(Despite my being reasonably knowledgable about splines and regression analysis) I have absolutely no idea what you mean by this statement:
"save the parameters of the fit at every point to use in regression analysis as my response"
Please clarify.
Ernest Modise - Kgamane
2021년 3월 2일
Hi D'Errico,
Kindly assist,
Using your code example:
x=[58.61111111 67.32055556 70.56194444 74.22694444 78.39388889 85.11555556];
y=[18.93000031 19.42000008 19.51000023 19.67000008 19.68000031 19.71999931];
S = spline(x,y)
S =
form: 'pp'
breaks: [58.611 67.321 70.562 74.227 78.394 85.116]
coefs: [5x4 double]
pieces: 5
order: 4
dim: 1
I get the following error
>> splineeg
Error: File: splineeg.m Line: 4 Column: 5
Invalid expression. Check for missing or extra characters.
What could be the mistake,
채택된 답변
추가 답변 (1개)
Shoaibur Rahman
2015년 2월 24일
pp = spline(x,y);
NewValue = [1 2]; % may be scaler or vector
out = ppval(pp,NewValue)
댓글 수: 3
Brandon
2015년 2월 24일
Shoaibur Rahman
2015년 2월 24일
Perhaps, you have already got it! coefficients are in pp. NewValue is any value used for interpolation using the coefficients in pp. Thanks.
oshawcole
2017년 9월 29일
How would you find a polynomial equation from the given x and y points?
카테고리
도움말 센터 및 File Exchange에서 Spline Postprocessing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!