using polyval with one of the polynomials of a spline obtained with the unmkpp command, the results do not overlap! Why?
I first interpolated some data using the spline command. Then I calculated the coefficients of the different cubic polynomials that make up the spline. Then I used the polyval command to check the first polynomial but the spline and polyval curves do not overlap.
What am I doing wrong?.
There is definitely something related to the various polynomials that I have not understood correctly. I thank anyone who helps me understand better. See the file script please:
%butta_sto_test
%
clear all
clc
% Data
% Time
Time=[7, 9, 11, 12]
% Temperture
Temperature=[49, 57, 71, 75]
% Data Time query
Timeq=[7:0.1:12];
% Results
% piecewise polynomial structure
pp=spline(Time, Temperature);
% Timeq data interpolation
Temperatureq=spline(Time, Temperature, Timeq);
% Calculating the coefficients of the 3 polynomials that make up the spline
[breaks, coeffs, m, n] = unmkpp(spline(Time,Temperature));
% First polinomial p1
p1=coeffs(1,:)
% First time interval corresponding to the first polynomial of the spline
Timeq1=[7:0.1:9];
% using polyval to calculate the values corresponding to Timeq1 using the polynomial p1
Temperatureq1=polyval(p1,Timeq1);
% Spline plot
figure(1)
plot(Timeq, Temperatureq, Time, Temperature, ‘o’, Time, Temperature, ‘–‘)
hold on
plot(Timeq1, Temperatureq1,’*’)
grid onI first interpolated some data using the spline command. Then I calculated the coefficients of the different cubic polynomials that make up the spline. Then I used the polyval command to check the first polynomial but the spline and polyval curves do not overlap.
What am I doing wrong?.
There is definitely something related to the various polynomials that I have not understood correctly. I thank anyone who helps me understand better. See the file script please:
%butta_sto_test
%
clear all
clc
% Data
% Time
Time=[7, 9, 11, 12]
% Temperture
Temperature=[49, 57, 71, 75]
% Data Time query
Timeq=[7:0.1:12];
% Results
% piecewise polynomial structure
pp=spline(Time, Temperature);
% Timeq data interpolation
Temperatureq=spline(Time, Temperature, Timeq);
% Calculating the coefficients of the 3 polynomials that make up the spline
[breaks, coeffs, m, n] = unmkpp(spline(Time,Temperature));
% First polinomial p1
p1=coeffs(1,:)
% First time interval corresponding to the first polynomial of the spline
Timeq1=[7:0.1:9];
% using polyval to calculate the values corresponding to Timeq1 using the polynomial p1
Temperatureq1=polyval(p1,Timeq1);
% Spline plot
figure(1)
plot(Timeq, Temperatureq, Time, Temperature, ‘o’, Time, Temperature, ‘–‘)
hold on
plot(Timeq1, Temperatureq1,’*’)
grid on I first interpolated some data using the spline command. Then I calculated the coefficients of the different cubic polynomials that make up the spline. Then I used the polyval command to check the first polynomial but the spline and polyval curves do not overlap.
What am I doing wrong?.
There is definitely something related to the various polynomials that I have not understood correctly. I thank anyone who helps me understand better. See the file script please:
%butta_sto_test
%
clear all
clc
% Data
% Time
Time=[7, 9, 11, 12]
% Temperture
Temperature=[49, 57, 71, 75]
% Data Time query
Timeq=[7:0.1:12];
% Results
% piecewise polynomial structure
pp=spline(Time, Temperature);
% Timeq data interpolation
Temperatureq=spline(Time, Temperature, Timeq);
% Calculating the coefficients of the 3 polynomials that make up the spline
[breaks, coeffs, m, n] = unmkpp(spline(Time,Temperature));
% First polinomial p1
p1=coeffs(1,:)
% First time interval corresponding to the first polynomial of the spline
Timeq1=[7:0.1:9];
% using polyval to calculate the values corresponding to Timeq1 using the polynomial p1
Temperatureq1=polyval(p1,Timeq1);
% Spline plot
figure(1)
plot(Timeq, Temperatureq, Time, Temperature, ‘o’, Time, Temperature, ‘–‘)
hold on
plot(Timeq1, Temperatureq1,’*’)
grid on spline unmkpp polyval interpolation MATLAB Answers — New Questions