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

• btbam91
In summary, the conversation discusses the issue of having nonsensical values plotted on a position vs time graph in MATLAB. The suggestions for solving this issue include giving less data points, changing the axis length, or implementing an if statement or iteration to stop plotting values when a certain condition is met.
btbam91
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.

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.

Yes, there is a way to set a termination point on a plot in MATLAB. You can use the "xlim" function to specify the range of values for the x-axis. For example, if you want the plot to stop at x=0, you can use the command "xlim([0, inf])" to set the x-axis limit to start at 0 and extend to infinity. This will stop the plot from continuing below 0. Additionally, you can also use the "ylim" function to specify the range of values for the y-axis, if needed. I hope this helps with your kinematics problem.

## 1. What is a termination point on a plot in MATLAB?

A termination point on a plot in MATLAB is the point at which the plot ends. It is useful for visualizing the end of a specific data set or for setting a limit on the x or y axis of the plot.

## 2. How do I set a termination point on a plot in MATLAB?

To set a termination point on a plot in MATLAB, you can use the "xlim" or "ylim" function. These functions allow you to specify the minimum and maximum values for the x and y axes, respectively, which effectively sets the termination point.

## 3. Can I set a termination point for only one axis on a plot?

Yes, you can set a termination point for only one axis on a plot in MATLAB. You can use the "xlim" or "ylim" function to specify the minimum and maximum values for the desired axis, while leaving the other axis unchanged.

## 4. What happens if I don't set a termination point on my plot?

If you don't set a termination point on your plot in MATLAB, the plot will continue to display all of the data points. This may result in a plot that is difficult to interpret or has unnecessary clutter. It is recommended to set a termination point to better visualize your data.

## 5. Can I change the termination point after the plot has been created?

Yes, you can change the termination point after the plot has been created in MATLAB. You can use the "xlim" or "ylim" function again with different values to change the termination point. Alternatively, you can also click and drag the edges of the plot in the figure window to adjust the termination point visually.

• Engineering and Comp Sci Homework Help
Replies
1
Views
941
• Engineering and Comp Sci Homework Help
Replies
2
Views
3K
• Engineering and Comp Sci Homework Help
Replies
2
Views
5K
• Engineering and Comp Sci Homework Help
Replies
1
Views
6K
• Engineering and Comp Sci Homework Help
Replies
1
Views
2K
• Engineering and Comp Sci Homework Help
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
3K
• Calculus and Beyond Homework Help
Replies
4
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K