Hi @Xiaobo Dong,
I do agree with @Walter Roberson’s comments,”fplot does not assume continuity. “ Let me address your query, A breakpoint in a function is a point where the function is not continuous. For example, the tangent function, tan(x), has vertical asymptotes at odd multiples of π/2. When fplot encounters these points, it must decide how to represent the function on either side of the discontinuity. So, when you run the command:
syms x fplot(tan(x), 'ShowPoles', 'off')
you may observe that the plot connects points on either side of certain breakpoints. This occurs because fplot evaluates the function at various points and, if the values are close enough, it will draw a line segment between them. The algorithm attempts to create a smooth curve, but it can sometimes connect points across a discontinuity if the evaluation points are not sufficiently spaced apart. Conversely, if the evaluation points around a discontinuity are spaced such that the function values diverge significantly (for instance, approaching infinity), fplot will not connect these points. This behavior is designed to prevent misleading representations of the function. To control whether the segments are connected or not, you can adjust the MeshDensity property of the fplot function. By increasing the mesh density, you can ensure that fplot evaluates the function at more points, which can help it better identify discontinuities and avoid connecting points across them. Here is an updated version of your code that increases the mesh density to better handle the discontinuities in the tangent function:
syms x % Increase the mesh density to improve the handling of discontinuities fplot(tan(x), 'ShowPoles', 'off', 'MeshDensity', 100) title('Plot of tan(x) with Increased Mesh Density') xlabel('x') ylabel('tan(x)') grid on
Please see attached.
For more information on MeshDensity, please refer to
Hope this helps.
Please let me know if you have any further questions.