Do anyone know how to graph your function in the interval from x=0 to inf

5 ビュー (過去 30 日間)
Phong Do
Phong Do 2021 年 1 月 16 日
コメント済み: Phong Do 2021 年 1 月 17 日
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;

採用された回答

Steven Lord
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 ExchangeSpline Postprocessing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by