# I want the graph of the function only show the part where x>0

5 vues (au cours des 30 derniers jours)
Phong Do le 12 Jan 2021
Commenté : Phong Do le 13 Jan 2021
I can't find any command that allows me to plot the function only in the interval [0 inf]
Here's my code, can you help me please
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 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Réponses (1)

Daniel Pollard le 12 Jan 2021
You want xlim. Give it one limit and it can calculate the other, or use
xlim(0, length(y)).
##### 1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Phong Do le 13 Jan 2021
Can you be more specific?
I put that line under the "fplot(y)" and then it occured the error
Error using xlim (line 31)
When 2 input arguments are specified, the first argument must be an axes.

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Programming dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by