您在這裡

Annotating Plots

20 一月, 2016 - 09:21

Graphs without labels are incomplete and labeling elements such as plot title, labels for x and y axes, and legend should be included. Using up arrow, recall the statement above and add the annotation commands as shown below.

x=[-pi:.1:pi];y=sin(x);plot(x,y);title('Graph of y=sin(x)');xlabel('x');ylabel('sin(x)');grid on

Run the file and compare your result with the first one.

media/image4.png
Figure 3.3 Graph of sin(x) with Labels. 
 

ASIDE: Type in the following at the MATLAB prompt and learn additional commands to annotate plots:

help gtext

help legend

help zlabel