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!