Hi,
In my understanding you have the coefficients of the cubic spline fitted for a graph. For converting the cubic spline coefficient into Horner nested polynomial representation you may try using horner. Below code may help plotting one of the cubic spline you may have. You may plot all spline with appropriate coefficients. syms x
a = rand(10,1);
b = rand(10,1);
c = rand(10,1);
d = rand(10,1);
p = a(1)*x^3 + b(1)*x^2 + c(1)*x + d(1);
horner_p = horner(p);
range_to_plot = -10:0;
fplot(horner_p,[range_to_plot(1),range_to_plot(2)]);
hold on
for i = 2:size(a,1)
p = a(i)*x^3 + b(i)*x^2 + c(i)*x + d(i);
horner_p = horner(p);
fplot(horner_p,[range_to_plot(i),range_to_plot(i+1)]);
end
hold off
Best Answer