Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Above is my attempt at writing the code which failed. Below is what you need to use to write the the code. 1. Rocket Trajectory
Above is my attempt at writing the code which failed. Below is what you need to use to write the the code.
1. Rocket Trajectory Computation: MATLAB Implementation O solutions submitted (max: Unlimited) This problem is designed to help you achieve the following course objectives: Understand basic principles of computer programming for numerical computation. Perform each of the above using structured professional-standard code. Problem Description: Implement the algorithm you developed in Part 1 of HW3 in a MATLAB function. Function e Reset MATLAB Documentation 5 function [h, V, n] = RocketTrajectoryidt, te, tf, ti, mo, c_de, c_di, mfdoto, ue, af) Input dt: time step (scalar) 4 to: initial time (scalar) tf: final tine scalar) 6 ti: time when parachute is to be deployed (scalar) 7 m: initial mass of rocket including fuel (scalar) BSC_de: drag coefficient before parachute deployment (scalar) 9 c_d1: drag coefficient after parachute deployment (scalar) 10 % mfdot: fuel mass flow rate (before fuel is burned up) (scalar) 11 % ue: exhaust velocity (scalar) 12 % mf: initial mass of fuel (scalar) 13 Output 14 h: time history of rocket altitude from to to tf (1 x N vector) 15 v: time history of rocket velocity from to to tf (1 x N vector) 16 % m: time history of rocket mass from to to tf (1 x N vector) 17 - 18 19 % Initialization 20 t = t:dt:tf; define the time vector: from to to tf with increment dt. 21 h = zeros(size(t)); 22 (1) = 8.0; initial altitude of rocket is 0.8 23 v = zeros(size(t)); 24 v(1) = 8.0; initial velocity of rocket is 8.0 25 i = zeros(size(t)); 26 mil) = m; initial mass of the rocket is given as input: mo. 27 g = 9.81; gravitational acceleration (m/s^2) 29 % calculate N: dimension of vector t 30 N = numel(t); 32 Write your function here. for i=1:N-1; if t(i)sat1 c_d=c_d1; else c_d=c_do; end end if mi)-(m-af)c= Thrust=; phi=8; 44 else Thrust=phixue; phi-phi0; 47 end 46 dvdt=-9-c_d/m(1)-(1) abs((1)) Thrust/m(i); v(1-1)=v( 1 )+dvdt dt; 53 h(i+1)=h(i)+v(i) dt; 55 m(i+1)=m( i )-phi-dt; 57 end Complete the following flow chart by filling the missing parts with the appropriate task numbers. Input: dt, to, tf, t1, mo, c_do c_di, phio, ue, mf Initialize vectors I, h, v, and m as discrete time instances, altitude, velocity, and mass: define g=9.81 (m's 2) Input variables: dt: time step (At); to: initial time; tf. final time; tl: time when parachute is to be deployed mo: initial mass of rocket (including fuel); c_do: drag coeff. before parachute deployment; c_dl: drag coeff. after parachute deployment; phio: rate of fuel consumption (before fuel is burned up); ue: exhaust velocity; mf: initial mass of fuel. calculate N = length(t) | B 1 Yes 10 2012 mono Yes 7. Yes No F cinstvo for i=1 to N for i=1 to N-1 3. define c d = c_do define c_d = c_d1 is mi) - (m0 - mf) 0? compute m(i + 1) = m(i) - phi * dt compute dvdt = -9 - c_d/m(i) *V(i) * (vi) + Thrust/m(i); 9. define Thrust = phi0 * ue; phi = phi0; 10. define Thrust = 0; phi = 0; 11. compute h(i + 1) = h(i) +v(i) * dt compute V1+1 = 0 + dvdt.dt Output: h, v. m Best Solution My Solutions Test Results Solution 4: All tests passed Submitted on 16 Feb 2020 at 22:26 | ID: 19518059 | Size: 36 O A HNM + OO 000 IL LLLLLLL L O I H. 1 A = 2; B = 4; 3 C = 3; 4 D = 5; 5 E = 10; 6 F = 9; G = 8; 8 H = 11; 9 I = 7; 10 % Note: This is just a template. It will not pass the test. You should change the right-hand-sides. 1. Rocket Trajectory Computation: MATLAB Implementation O solutions submitted (max: Unlimited) This problem is designed to help you achieve the following course objectives: Understand basic principles of computer programming for numerical computation. Perform each of the above using structured professional-standard code. Problem Description: Implement the algorithm you developed in Part 1 of HW3 in a MATLAB function. Function e Reset MATLAB Documentation 5 function [h, V, n] = RocketTrajectoryidt, te, tf, ti, mo, c_de, c_di, mfdoto, ue, af) Input dt: time step (scalar) 4 to: initial time (scalar) tf: final tine scalar) 6 ti: time when parachute is to be deployed (scalar) 7 m: initial mass of rocket including fuel (scalar) BSC_de: drag coefficient before parachute deployment (scalar) 9 c_d1: drag coefficient after parachute deployment (scalar) 10 % mfdot: fuel mass flow rate (before fuel is burned up) (scalar) 11 % ue: exhaust velocity (scalar) 12 % mf: initial mass of fuel (scalar) 13 Output 14 h: time history of rocket altitude from to to tf (1 x N vector) 15 v: time history of rocket velocity from to to tf (1 x N vector) 16 % m: time history of rocket mass from to to tf (1 x N vector) 17 - 18 19 % Initialization 20 t = t:dt:tf; define the time vector: from to to tf with increment dt. 21 h = zeros(size(t)); 22 (1) = 8.0; initial altitude of rocket is 0.8 23 v = zeros(size(t)); 24 v(1) = 8.0; initial velocity of rocket is 8.0 25 i = zeros(size(t)); 26 mil) = m; initial mass of the rocket is given as input: mo. 27 g = 9.81; gravitational acceleration (m/s^2) 29 % calculate N: dimension of vector t 30 N = numel(t); 32 Write your function here. for i=1:N-1; if t(i)sat1 c_d=c_d1; else c_d=c_do; end end if mi)-(m-af)c= Thrust=; phi=8; 44 else Thrust=phixue; phi-phi0; 47 end 46 dvdt=-9-c_d/m(1)-(1) abs((1)) Thrust/m(i); v(1-1)=v( 1 )+dvdt dt; 53 h(i+1)=h(i)+v(i) dt; 55 m(i+1)=m( i )-phi-dt; 57 end Complete the following flow chart by filling the missing parts with the appropriate task numbers. Input: dt, to, tf, t1, mo, c_do c_di, phio, ue, mf Initialize vectors I, h, v, and m as discrete time instances, altitude, velocity, and mass: define g=9.81 (m's 2) Input variables: dt: time step (At); to: initial time; tf. final time; tl: time when parachute is to be deployed mo: initial mass of rocket (including fuel); c_do: drag coeff. before parachute deployment; c_dl: drag coeff. after parachute deployment; phio: rate of fuel consumption (before fuel is burned up); ue: exhaust velocity; mf: initial mass of fuel. calculate N = length(t) | B 1 Yes 10 2012 mono Yes 7. Yes No F cinstvo for i=1 to N for i=1 to N-1 3. define c d = c_do define c_d = c_d1 is mi) - (m0 - mf) 0? compute m(i + 1) = m(i) - phi * dt compute dvdt = -9 - c_d/m(i) *V(i) * (vi) + Thrust/m(i); 9. define Thrust = phi0 * ue; phi = phi0; 10. define Thrust = 0; phi = 0; 11. compute h(i + 1) = h(i) +v(i) * dt compute V1+1 = 0 + dvdt.dt Output: h, v. m Best Solution My Solutions Test Results Solution 4: All tests passed Submitted on 16 Feb 2020 at 22:26 | ID: 19518059 | Size: 36 O A HNM + OO 000 IL LLLLLLL L O I H. 1 A = 2; B = 4; 3 C = 3; 4 D = 5; 5 E = 10; 6 F = 9; G = 8; 8 H = 11; 9 I = 7; 10 % Note: This is just a template. It will not pass the test. You should change the right-hand-sidesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started