Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can I please get some help with problem 4? I need to use a function. The functio

ID: 3851808 • Letter: C

Question

Can I please get some help with problem 4? I need to use a function. The functions and the code that needs to be modified is included below.

clc
clear
disp('ENGR15100 Prelab 9')
disp('Your name here')
disp(' ')
%Run script file for rocket calculations
rocket2h2
%rocket2h2.m
%
clc
b=input('Enter desired burn time ');
disp(' ')
h_des=input('Enter desired height ');
disp(' ')
dt=.1;
m=10;
f=2000;
g=32.2;
%calculate constants
v_b=(f/m-g)*b;
h_b=0.5*(f/m-g)*b^2;
h_p=h_b+v_b^2/(2*g);
t_p=b+v_b/g;
figure(2)
%Begin calculating flight
h=0;
k=0;
while h>=0
t=k*dt;
k=k+1;
if t<=b
h=0.5*(f/m-g)*t^2;
v=(f/m-g)*t;
else
%calc rest of unpowered ascent
h=h_b-.5*g*(t-b)^2+v_b*(t-b);
v=v_b-g*(t-b);
end
plot(t,h,'b.')
hold on
end
%disp('Time to desired height is:')
disp('Time to hit the ground is:')
disp(t)
disp(' ')
hold off
%Next based on burn time and desired altitude the code will determine time to reach
%altitude if possible check if peak height greater than altitude desired.
if h_p>h_des %do-able!
h=0;
k=0;
t=0;
while h<h_des
t=k*dt;
k=k+1;
if t<=b
h=0.5*(f/m-g)*t^2;
v=(f/m-g)*t;
else
%calc rest of unpowered ascent
h=h_b-.5*g*(t-b)^2+v_b*(t-b);
v=v_b-g*(t-b);
end
end
disp('Time to desired height is:')
disp(t)
else
disp('Rocket will not achieve desired altitude of:')
disp(h_des)
end

STEP 1: Create six function files %Create the function file lastname-get-bm function b= lastname-get-b() b input(Enter desired engine burn time b in seconds '); disp(') 2 Create the function file lastname_get_f.m function f lastname_get f 0 f-input('Enter desired engine force f in Ibs'; disp( ') %Create the function file lastname get dt.m function dt= lastname get dt() dt-input(Enter desired simulation time step dt in sec '); disp(') 4 %Create the function file lastname-get-h-des.m function h des- lastname get h des ( h des-input('Enter desired altitude h des in feet ') disp( ') 4a %Create the function file lastname-get-m.m function m=lastname-get-m() m=input('Enter desired rocket weight m in pounds); disp(') %Create the function file lastname calc perf.m function [v_b,h_b,t p,h _p]-lastname_calc_perf (b,m,f,g) h b= 0.5*(f/m-g)"b"2; 6 %Create the function file lastname calc hv.m function [h,v]=lastname. calc-hv (b.m.f.gth-by-b) if t

Explanation / Answer

Answer for the question:

This given code is chenged the while loop with for loop and displayed the data with the help of fprintf for project 4

clc
clear
disp('ENGR15100 Prelab 9')
disp('Your name here')
disp(' ')
%Run script file for rocket calculations
rocket2h2
%rocket2h2.m
%
clc
b=input('Enter desired burn time ');
disp(' ')
h_des=input('Enter desired height ');
disp(' ')
dt=.1;
m=10;
f=2000;
g=32.2;
%calculate constants
v_b=(f/m-g)*b;
h_b=0.5*(f/m-g)*b^2;
h_p=h_b+v_b^2/(2*g);
t_p=b+v_b/g;
figure(2)
%Begin calculating flight
h=0;
k=0;
for k = 1:h
%while h>=0
t=k*dt;
k=k+1;
if t<=b
h=0.5*(f/m-g)*t^2;
v=(f/m-g)*t;
else
%calc rest of unpowered ascent
h=h_b-.5*g*(t-b)^2+v_b*(t-b);
v=v_b-g*(t-b);
end
plot(t,h,'b.')
hold on
end
%disp('Time to desired height is:')
fprintf('Time to hit the ground is:')
fprintf(t)
fprintf(' ')
hold off
%Next based on burn time and desired altitude the code will determine time to reach
%altitude if possible check if peak height greater than altitude desired.
if h_p>h_des %do-able!
h=0;
k=0;
t=0;
while h<h_des
t=k*dt;
k=k+1;
if t<=b
h=0.5*(f/m-g)*t^2;
v=(f/m-g)*t;
else
%calc rest of unpowered ascent
h=h_b-.5*g*(t-b)^2+v_b*(t-b);
v=v_b-g*(t-b);
end
end
fprintf('Time to desired height is:')
fprintf(t)
else
fprintf('Rocket will not achieve desired altitude of:')
fprintf(h_des)
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote