1
0
mirror of https://gitlab.com/lander-team/lander-sim.git synced 2025-08-02 19:31:28 +00:00

added plot generation for readme

This commit is contained in:
2021-04-21 21:54:50 -07:00
parent 713823956c
commit 29d2c6cff1
6 changed files with 44 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

BIN
outputs/Altitude.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -1,5 +1,12 @@
# Lander Landing Simulation
## Results
![Altitude Over Time Animation](outputs/Altitude.gif)
![Acceleration vs Time](outputs/Acceleration%20vs%20Time.png)
![Velocity vs Time](outputs/Velocity%20vs%20Time.png)
![Altitude vs Time](outputs/Altitude%20vs%20Time.png)
## Requirements
- Aerospace Toolbox

View File

@@ -36,6 +36,8 @@ plot(simOut.a)
title('Acceleration vs Time')
xlabel('Time (s)')
ylabel('Acceleration (g''s)')
legend('X','Y')
saveas(gcf,'outputs/Acceleration vs Time.png')
% Velocity
figure(2)
@@ -43,27 +45,58 @@ plot(simOut.v)
title('Velocity vs Time')
xlabel('Time (s)')
ylabel('Velocity (m/s)')
legend('X','Y')
saveas(gcf,'outputs/Velocity vs Time.png')
% Altitude
figure(3)%k)
plot(simOut.h)
plot(sqrt(simOut.h.Data(:,2).^2 + simOut.h.Data(:,1).^2), simOut.h.Time)
title('Altitude vs Time')
% title(['burnStart = ',num2str(burnStart),' s'])
xlabel('Time (s)')
ylabel('Altitude (m)')
saveas(gcf,'outputs/Altitude vs Time.png')
% Animation
figure(4)
h = figure(4);
K = animatedline('Marker', 'o');
axis([0, 2, 0, h_0])
title('2-D Animation')
xlabel('X-Position (m)')
ylabel('Altitde (m)')
ylabel('Altitude (m)')
title('Altitude')
grid on
for i = 1 : length(simOut.h.Data)
clearpoints(K);
addpoints(K, 1, simOut.h.Data(i, 2));
title(sprintf('Altitude at T = %f', simOut.h.Time(i)))
drawnow limitrate
% Write Animation to gif, set to zero when testing since its slow to render.
outframes = 0;
if outframes
% Write to the GIF File
if i == 1
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
%initalize plot
imwrite(imind,cm,'outputs/Altitude.gif','gif', 'Loopcount',inf);
elseif mod(i,floor(length(simOut.h.Data)/outframes)) == 0
% Capture the plot as an image
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
% Append to plot
imwrite(imind,cm,'outputs/Altitude.gif','gif','WriteMode','append', 'DelayTime', .2);
end
end
end