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

Click For Summary

Discussion Overview

The discussion revolves around a MATLAB issue related to plotting a position vs time graph for a kinematics problem involving a ball dropped from a height. Participants explore methods to prevent the plot from displaying values below a specified threshold, in this case, when the position reaches zero.

Discussion Character

  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant notes that MATLAB will plot all provided data points and suggests reducing the number of data points or adjusting the axis limits to hide unwanted values.
  • Another participant proposes using an if statement to set the x value to zero when the y value reaches zero.
  • A different approach mentioned involves iterating through the results and slicing the vector based on a condition related to the absolute value of the position, although this method is described as not particularly elegant.

Areas of Agreement / Disagreement

Participants present multiple approaches to the problem, indicating that there is no consensus on a single solution. Various methods are suggested, each with different implications for implementation.

Contextual Notes

Some methods depend on specific definitions of the problem, such as the threshold for stopping the plot, and the effectiveness of each approach may vary based on the data provided.

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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
1
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
1
Views
2K