clear;
clc;
q0=0;q1=100;
v0=0;v1=0;
a_0=0;a_1=0;
j0=0;j1=0;
t0=0;t1=1;
T=t1-t0;
Q=q1-q0;
a0=q0;
a1=v0;
a2=1/2*a_0;
a3=1/6*j0;
a4=(210*Q-T*((30*a_0-15*a_1)*T+(4*j0+j1)*power(T,2)+120*v0+90*v1))/(6*power(T,4));
a5=(-168*Q+T*((20*a_0-14*a_1)*T+(2*j0+j1)*power(T,2)+90*v0+78*v1))/(2*power(T,5));
a6=(420*Q-T*((45*a_0-39*a_1)*T+(4*j0+3*j1)*power(T,2)+216*v0+204*v1))/(6*power(T,6));
a7=(-120*Q+T*((12*a_0-12*a_1)*T+(j0+j1)*power(T,2)+60*v0+60*v1))/(6*power(T,7));
t=t0:0.01:t1;
q=a0+a1*power((t-t0),1)+a2*power((t-t0),2)+a3*power((t-t0),3)+a4*power((t-t0),4)+a5*power((t-t0),5)+a6*power((t-t0),6)+a7*power((t-t0),7);
v=a1+2*a2*power((t-t0),1)+3*a3*power((t-t0),2)+4*a4*power((t-t0),3)+5*a5*power((t-t0),4)+6*a6*power((t-t0),5)+7*a7*power((t-t0),6);
a=2*a2+6*a3*power((t-t0),1)+12*a4*power((t-t0),2)+20*a5*power((t-t0),3)+30*a6*power((t-t0),4)+42*a7*power((t-t0),5);
j=6*a3+24*a4*power((t-t0),1)+60*a5*power((t-t0),2)+120*a6*power((t-t0),3)+210*a7*power((t-t0),4);
subplot(4,1,1);plot(t,q,'k');ylabel('位置(°)');
grid on;
subplot(4,1,2);plot(t,v,'k');ylabel('速度(°/s)');
grid on;
subplot(4,1,3);plot(t,a,'k');ylabel('加速度(°/二次方秒)');
grid on;
subplot(4,1,4);plot(t,j,'k');ylabel('加加速度°/三次方秒');xlabel('时间s');
grid on;
% plot(t,q,'k');ylabel('位置(°)');xlabel('时间s');
% plot(t,j,'k');ylabel('加加速度(°/s^3)');xlabel('时间s');
% plot(t,a,'k');ylabel('加速度(°/s^2)');xlabel('时间s');
%plot(t,v,'k');ylabel('速度(°/s)');xlabel('时间s');
%
% clear;clc;
% t0=0;t1=1;
% a0=-30;a1=0;a2=0;a3=2200;a4=-4950;a5=3960;a6=-1100;
% t=t0:0.01:t1;
% q=a0+a1*power((t-t0),1)+a2*power((t-t0),2)+a3*power((t-t0),3)+a4*power((t-t0),4)+a5*power((t-t0),5)+a6*power((t-t0),6);
% v=a1+2*a2*power((t-t0),1)+3*a3*power((t-t0),2)+4*a4*power((t-t0),3)+5*a5*power((t-t0),4)+6*a6*power((t-t0),5);
% a=2*a2+6*a3*power((t-t0),1)+12*a4*power((t-t0),2)+20*a5*power((t-t0),3)+30*a6*power((t-t0),4);
% j=6*a3+24*a4*power((t-t0),1)+60*a5*power((t-t0),2)+120*a6*power((t-t0),3);
% subplot(4,1,1);plot(t,q,'r');ylabel('position');
% grid on;
% subplot(4,1,2);plot(t,v,'b');ylabel('velocity');
% grid on;
% subplot(4,1,3);plot(t,a,'y');ylabel('acceleration');
% grid on;
% subplot(4,1,4);plot(t,j,'g');ylabel('jerk');
% grid on;