commit c57405e670667417a9ed41cc51f7ff2f731d076e Author: Brendan McGeeney Date: Tue Apr 20 04:04:35 2021 +0000 Upload New File diff --git a/simPrototypeSTART.m b/simPrototypeSTART.m new file mode 100644 index 0000000..4009806 --- /dev/null +++ b/simPrototypeSTART.m @@ -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 +