After drawing a two-dimensional plane image, sometimes we want to draw the coordinate line of the specified coordinate point, and want to make some annotations on the point, however, this point may change with our input.
The plot function can be used to draw a straight line between two points. This method can be used to draw the desired coordinate line.
When the text function is used for annotation, the annotation s in text (X, Y, S) is a string marked at [x, y, if the vertex we want to mark may change, it is obviously not possible to directly use the string in the text function. We can use the sprintf function to first obtain the string we want to mark, then use the text function annotation.
For example, we want to mark the coordinate value of this vertex at [3, 3] on the image of the Y = x function.
Ezplot ('x', 'B ');
Axis ([0, 5, 0, 5]);
Hold on
Plot ([], [], 'B', [], [], 'B ');
Syms x
F = x ^ 3 + 2 * X;
A = Subs (f, x, 1 );
Hold on
Plot (a, a, 'r *');
S = sprintf ('two spaces to get a better position [% d, % d] ', a, );
Text (a, a, S );
Shows the obtained image.
After MATLAB draws an image, draw the coordinate line and annotation variable at the specified point.