我有一组值(它们代表放射线的角度变化),我开始创建一个插值所有值的多项式 .

time = 10;
n = 10*time;
t = linspace(0,time,n);
%Th1 is the array of angles 
p1 = polyfit(t,Th1,5); %fifth-grade polynomial

然后我想要一个带边界条件的多项式:在t = 0(第一个值)和t =时间(最后一个值)时,第一个和第二个推导都必须等于零 . 角度从Th1_start变为Th1_end . 我作为线性系统解决了这个问题

t_start = 0;
t_end = time;
syms t;
Mat = [1 t t^2 t^3 t^4 t^5; 0 1 2*t 3*(t^2) 4*(t^3) 5*(t^4); 0 0 2 6*t 12*(t^2) 20*(t^3)];
%Mat is a matrix with 3 rows. Given in the first row a generic fifth-grade polynomial 
%(an angle with respect to the time t) the second row is the first derivate 
%and the third row is the second derivate of the polynomial
%initialize the array to store coefficients
P_theta = zeros(1,6);
%first three rows when t = 0
t = t_start;
A = subs(Mat);
%other rows evaluated when t = time
t = t_end;
B = subs(Mat);
%creating the matrix C and the array V of bounds for the system. 
C = vertcat(A,B);
V = [th_start(i) 0 0 th_end(i) 0 0]';
XX = linsolve(C,V);
P_theta(1,:) = XX;

系统具有6维,因为给出了6个边界:2个点(第一个和最后一个)和4个关于这些点中的导数的条件 . 找到6个系数 .

现在的问题是:我有很多要点(比如第一种情况),我想在第一点和最后一点添加关于派生的4个可选条件(如第二种情况) . 在没有编写(N 4)阶系统的情况下,Matlab中是否有快速找到正确多项式的方法?

一个小例子 . 我获得了10分

th1 = [0.0840 0.1480 0.2127 0.2792 0.3478 0.4188 0.4926 0.5693 0.6496 0.7338]

使用 polyfit 我将获得一些满足条件的系数(命名Th1(t)理想多项式)(伪代码)

Th1(t = 0) = th(1)
Th1(t = time) = th(10)

并且隐式地,多项式满足所有其他8个条件(如果多项式的次数大于/等于10) . 系统满足这些类型的条件,但插值不满足 .

Th1(t(i)) = th1(i)

但不满足这4个条件(伪代码)

d(Th1(t = 0))/dt = 0 %first derivate evaluated in t = 0
d(Th1(t = time))/dt = 0 %first derivate evaluated in t = 0
d2(Th1(t = 0))/dt = 0 % second derivate evaluated in t = time
d2(Th1(t = time))/dt = 0 %first derivate evaluated in t = 0

有14个条件 . 我想避免用14个方程写一个线性系统 . 我不想丢弃矿石选择一些点以减少方程式 . 如何将这4个条件添加到polyfit等方法中?

谢谢大家 .