mirror of
https://gitlab.com/lander-team/lander-sim.git
synced 2025-08-02 19:31:28 +00:00
Upload New File
This commit is contained in:
69
simPrototypeSTART.m
Normal file
69
simPrototypeSTART.m
Normal file
@@ -0,0 +1,69 @@
|
||||
%% LANDER SIM PROTOTYPE
|
||||
close all; clear all; clc;
|
||||
|
||||
%% User Defined Values
|
||||
% Initial Conditions
|
||||
v_0 = 0; % Initial Velocity [m/s]
|
||||
|
||||
% Thrust Curve Data from Text File [t, N]
|
||||
Tcurve = readmatrix('F15_thrustCurve.txt');
|
||||
|
||||
% Constants
|
||||
g = -9.81; % Gravitational Acceleration [m/s2]
|
||||
M0 = 0.8; % Initial Mass [kg]
|
||||
Mp = 0.06; % Propellant Mass [kg]
|
||||
Mb = M0 - Mp; % Burnout Mass [kg]
|
||||
tb = Tcurve(end, 1); % Burn Time [s]
|
||||
mdot = Mp / tb; % Mass Flow Rate [kg/s]
|
||||
D = 0; % Drag [N]
|
||||
stepSize = 0.001; % Simulation Step Size [s]
|
||||
|
||||
[h_0, vb, burnStartTime] = burnStartTimeCalc(Tcurve, tb, M0, mdot, Mb)
|
||||
|
||||
%% Simulink
|
||||
tic
|
||||
simTime = burnStartTime + tb; % Simulation Time [s]
|
||||
|
||||
model = 'simProtoype';
|
||||
load_system(model);
|
||||
simOut = sim(model);
|
||||
|
||||
toc
|
||||
%% Output
|
||||
% Acceleration
|
||||
figure(1)
|
||||
plot(simOut.a)
|
||||
title('Acceleration vs Time')
|
||||
xlabel('Time (s)')
|
||||
ylabel('Acceleration (g''s)')
|
||||
|
||||
% Velocity
|
||||
figure(2)
|
||||
plot(simOut.v)
|
||||
title('Velocity vs Time')
|
||||
xlabel('Time (s)')
|
||||
ylabel('Velocity (m/s)')
|
||||
|
||||
% Altitude
|
||||
figure(3)%k)
|
||||
plot(simOut.h)
|
||||
title('Altitude vs Time')
|
||||
% title(['burnStart = ',num2str(burnStart),' s'])
|
||||
xlabel('Time (s)')
|
||||
ylabel('Altitude (m)')
|
||||
|
||||
% Animation
|
||||
figure(4)
|
||||
K = animatedline('Marker', 'o');
|
||||
axis([0, 2, 0, h_0])
|
||||
title('2-D Animation')
|
||||
xlabel('X-Position (m)')
|
||||
ylabel('Altitde (m)')
|
||||
grid on
|
||||
|
||||
for i = 1 : length(simOut.h.Data)
|
||||
clearpoints(K);
|
||||
addpoints(K, 1, simOut.h.Data(i, 2));
|
||||
drawnow limitrate
|
||||
end
|
||||
|
Reference in New Issue
Block a user