Please help: How to do a time step?
Afficher commentaires plus anciens
Here is my code, i need the final velocity from u_1 to be the initial velocity for u_2. How do i do this please?
close all
clc;
%define variables
mi_1=2290000;
mf_1=130000;
tb_1=165;
Isp_1=263;
mi_2=496200;
mf_2=40100;
tb_2=360;
Isp_2=421;
mi_3=123000;
mf_3=13500;
tb_3=500;
Isp_3=421;
g=9.81; %acceleration due to gravity
%stage 1
t_1=linspace(0,165);
mr_1=mi_1-((mi_1-mf_1)*(t_1/tb_1));
u_1=g.*(Isp_1.*log(mi_1./mr_1)-t_1); %velocity function
a_1=gradient(u_1, t_1(2)-t_1(1)); %differentiation of velocity function to get acceleration
p_1= cumtrapz(t_1,u_1); %integration of velocity function to get position
%end of stage 1
%stage 2
t_2=linspace(165,525);
mr_2=mi_2-((mi_2-mf_2)*(t_2/tb_2));
u_2=g.*(Isp_2.*log(mi_2./mr_2)-t_2);
a_2=gradient(u_2, t_2(2)-t_2(1));
p_2= cumtrapz(t_2,u_2);
%end of stage 2
%stage 3
t_3=linspace(525,1025);
mr_3=mi_3-((mi_3-mf_3)*(t_3/tb_3));
u_3=g.*(Isp_3.*log(mi_3./mr_3)-t_3);
a_3=gradient(u_3, t_3(2)-t_3(1));
p_3= cumtrapz(t_3,u_3);
%end of stage 3
%position-time graph
figure
plot(t_1,p_1,'blue',t_2,p_2,'blue',t_3,p_3,'blue')
title('Position')
ylabel('height[m]')
xlabel('time[s]')
%velocity-time graph
figure
plot(t_1,u_1,'red',t_2,u_2,'red',t_3,u_3,'red')
title('Velocity')
ylabel('Velocity[m/s]')
xlabel('time[s]')
%acceleration-time graph
figure
plot(t_1,a_1,'green',t_2,a_2,'green',t_3,a_3,'green')
title('Acceleration')
ylabel('Acceleration[m/s^2]')
xlabel('time[s]')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



