Save cubic spline coefficients to use as response in regression
Mostrar comentarios más antiguos
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 comentarios
John D'Errico
el 24 de Feb. de 2015
(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
el 2 de Mzo. de 2021
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,
Respuesta aceptada
Más respuestas (1)
Shoaibur Rahman
el 24 de Feb. de 2015
pp = spline(x,y);
NewValue = [1 2]; % may be scaler or vector
out = ppval(pp,NewValue)
3 comentarios
Brandon
el 24 de Feb. de 2015
Shoaibur Rahman
el 24 de Feb. de 2015
Perhaps, you have already got it! coefficients are in pp. NewValue is any value used for interpolation using the coefficients in pp. Thanks.
oshawcole
el 29 de Sept. de 2017
How would you find a polynomial equation from the given x and y points?
Categorías
Más información sobre Spline Postprocessing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!