Quadratic spline having shape preserving property

조회 수: 6 (최근 30일)
Mohammad Shojaei Arani
Mohammad Shojaei Arani 2022년 5월 29일
답변: Mohammad Shojaei Arani 2022년 5월 30일
Hello friends,
In my work I need to use quadratic splines and I can use the command spapi(3,x_data,y_data). Unfortunately, I cannot find a quadratic
spline framework in matlab which also supports 'Shape preserving'. I know that pchip can do the job for cubic splines but to speed up
my codes I cannot use pchip, unfortunately.
I am wondering whether matlab can do what I need? I am
Thanks for your help, in advance!
Babak

채택된 답변

John D'Errico
John D'Errico 2022년 5월 29일
You cannot define a shape preserving quadratic spline that is differentiable across the breaks.
So while you think you want it, you will be unhappy with the result, even if you did manage to formulate such an animal.
Why you cannot use pchip I don't know, because pchip will be extrmely fast. My guess is you are not using pchip efficiently, but I have no clue as to what it is you are doing with the code, so that is difficult to guess. But I will claim that any quadratic spline you do formulate will not provide any significant speedup over pchip, IF used properly. There will be many other places in your code where you would gain far more, even if you could find some insignificant speed gains over pchip.

추가 답변 (1개)

Mohammad Shojaei Arani
Mohammad Shojaei Arani 2022년 5월 30일
Hello John,
I did not know that a shape preserving quardatic spline cannot be smooth at breaks. Yes, I agree with you that I
will not be happy with it. A pity!
The reason I need to use quadratic splines has a totally different reason than splines themselves. Yes, cubic splines and pchip are quite fast in matlab. In short I am working on an algorithm whose very lengthy expressions contain the higher derivatives of my function f. So, if I can interpolate f with a quadratic spline, instead of a cubic spline, then I can hugely shorten those long expressions and hence reduce the computational time. But, I also want the interpolating spline to be smooth and this is why I did not want to use linear splines (although I would love to do so!).
Thanks for your illuminating answer John!
Regards,
Babak

카테고리

Help CenterFile Exchange에서 Splines에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by