Quick MATLAB help -> Setting a termination point on a plot.

Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
3 replies · 2K views
btbam91
Messages
91
Reaction score
0
Quick MATLAB help --> Setting a termination point on a plot.

I have this kinematics problem on dropping a ball from a building a few meters high. When I plot the position vs time graph, it starts at let's say 50 meters high, I get a plot of an upside down parabola, as expected, but my plot continues down below 0. Is there a way to tell MATLAB to stop calculating/plotting values when x=0?

Thanks.
 
Physics news on Phys.org


It will plot all the data points you give it... so give it less data points if some are nonsensical or change the axis length to cut them out of view!
 


Place an if statement such that if y=0, then x=0.
 


Sometimes I'll iterate through the results and slice the vector where the absolute value of the i-th element subtracted from zero is less than some epsilon. Not particularly elegant, but it works.