animatedline
函数,如果Matlab,但我只是卡在这里。我的功能只显示сordinordinate轴而已。
飞机的坐标在飞行期间从Simulink模型进入。 拜托,帮助我!
function trajectory(uu)
pn = uu(1); % inertial North position
pe = uu(2); % inertial East position
pd = uu(3); % inertial Down position
t = uu(4); % time
if t==0,
figure(10), clf
S = 1500;
view(0,90)
axis([-S,S,-S,S,-.1, S]);
grid on
drawnow
else
h = animatedline;
x=pe, y=pn; z=-pd;
addpoints (h, x, y, z);
drawnow
end
答案 0 :(得分:0)
您正在尝试使用句柄h
绘图,但在函数调用结束时会被销毁。我提出以下解决方案,
% Function
function trajectory(uu, hLine)
pn = uu(1); % inertial North position
pe = uu(2); % inertial East position
pd = uu(3); % inertial Down position
x = pe; y = pn; z = -pd;
addpoints (hLine, x, y, z);
drawnow
end
% script
figure(10);
S = 1500;
view(0,90)
axis([-S, S, -S, S, -.1, S]);
grid on
lineHandle = animatedline('Color','r','LineWidth',3);
for i = 1:nPoints
% replace this with your value
currentValue = 1000*rand(1, 4);
trajectory(currentValue, lineHandle);
end