Do anyone know how to graph your function in the interval from x=0 to inf
1 次查看(过去 30 天)
显示 更早的评论
So i have a problem to find the equation of motion of rocket and plotting it, but when plotting the graph it keeps plotting the part where x is negative
Here it's my code, can someone help me to only plot the part where x>0
Many thanks in advance
syms t positive rational
disp ('Choose upward direction as positive direction');
disp ('Choose ground as the origin of coordinates');
fprintf ('The Newton''s second law equation for rocket motion: ');
disp ('m*dv/dt = -v0*dm/dt - mg');
k = input('Input the fuel combustion speed dm/dt = ');
m0 = input('The rocket''s mass m0 = ');
y0 = input('The rocket''s initial position y0 = ');
v0 = input('The rocket''s gas propulsion speed v0 = ');
g = 9.81;
v = v0*log(m0/(m0-k*t))-g*t;
a = diff(v,t);
fprintf ('The rocket''s acceleration: a = ');
disp (a);
y = y0 + int(v,0,t);
fprintf ('the equation of rocket motion : y =');
disp (y);
fplot(y);
title('Graph of the motion''s equation');
xlabel('Time t');
ylabel('Position y');
grid on;
0 个评论
采纳的回答
Steven Lord
2021-1-16
The fplot function allows you to specify the range of x over which you want your function to be plotted.
syms x
fplot(sin(x), [0 4*pi])
But you're not going to be able to achieve the goal in your question as stated unless you have an infinitely wide monitor. You could pan the axes to see the plot for larger and larger values of x, but you're never going to be able to get an infinitely wide view.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Argument Definitions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!