Plot path of a aicraft by plot3

1 次查看(过去 30 天)
x0 = 0;
y0 = 0;
z0 = 0;
V = 100;
t_start = 0;
t_end = 100;
delta_t = 1;
t = t_start:delta_t:t_end;
for i = 1:length(t)
chi = 1 + sin(i)^2;
gamma = 1+ cos(i)^2;
x_new = delta_t*(V*cos(chi)*cos(gamma)) + x0;
y_new = delta_t*(V*sin(chi)*cos(gamma)) + y0;
z_new = -delta_t*(V*cos(gamma)) + z0;
x0 = x_new;
y0 = y_new;
z0 = z_new;
plot3(x_new, y_new, z_new, '.');
hold on
zlabel('t')
end
I have lines of code. And i want to draw a path of aircraft in plot 3D but my result just show point. Help me!!!

采纳的回答

Les Beckham
Les Beckham 2023-2-6
t_start = 0;
t_end = 100;
delta_t = 1;
t = t_start:delta_t:t_end;
x = zeros(size(t));
y = zeros(size(t));
z = zeros(size(t));
x(1) = 0;
y(1) = 0;
z(1) = 0;
V = 100;
for i = 2:length(t)
chi = 1 + sin(i)^2;
gamma = 1+ cos(i)^2;
x(i) = delta_t*(V*cos(chi)*cos(gamma)) + x(i-1);
y(i) = delta_t*(V*sin(chi)*cos(gamma)) + y(i-1);
z(i) = -delta_t*(V*cos(gamma)) + z(i-1);
end
plot3(x, y, z, '.');
grid
  2 个评论
Khánh Tân
Khánh Tân 2023-2-6
How do i draw a path between point. Your result just show point
Les Beckham
Les Beckham 2023-2-6
Change the plot3 command as shown below:
t_start = 0;
t_end = 100;
delta_t = 1;
t = t_start:delta_t:t_end;
x = zeros(size(t));
y = zeros(size(t));
z = zeros(size(t));
x(1) = 0;
y(1) = 0;
z(1) = 0;
V = 100;
for i = 2:length(t)
chi = 1 + sin(i)^2;
gamma = 1+ cos(i)^2;
x(i) = delta_t*(V*cos(chi)*cos(gamma)) + x(i-1);
y(i) = delta_t*(V*sin(chi)*cos(gamma)) + y(i-1);
z(i) = -delta_t*(V*cos(gamma)) + z(i-1);
end
plot3(x, y, z);
grid

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by