纵向匀速横向五次多项式规划matlab代码
时间: 2023-05-29 18:06:33 浏览: 111
机械臂轨迹规划之五次多项式插值规划matlab仿真代码
5星 · 资源好评率100%
这里提供一份纵向匀速横向五次多项式规划的MATLAB代码,仅供参考:
```matlab
% 输入起始点、终点、时间间隔
start_point = [0, 0];
end_point = [10, 10];
dt = 0.1;
% 求取水平和垂直方向的距离和速度
dx = end_point(1) - start_point(1);
dy = end_point(2) - start_point(2);
vx = dx / (5*dt);
vy = dy / (5*dt);
% 构造五次多项式规划
t = 0:dt:5*dt;
a0 = start_point;
a1 = [vx/5, vy/5];
a2 = [0, 0];
a3 = [-10*vx/(5*dt^3), -10*vy/(5*dt^3)];
a4 = [15*vx/(5*dt^4), 15*vy/(5*dt^4)];
a5 = [-6*vx/(5*dt^5), -6*vy/(5*dt^5)];
x = a0(1) + a1(1)*t + a2(1)*t.^2 + a3(1)*t.^3 + a4(1)*t.^4 + a5(1)*t.^5;
y = a0(2) + a1(2)*t + a2(2)*t.^2 + a3(2)*t.^3 + a4(2)*t.^4 + a5(2)*t.^5;
% 绘制图像
plot(x, y);
axis equal;
grid on;
```
阅读全文