1、命令行键入:x1 = linspace(0,5);%定义x1。
2、命令行键入:y1 = sin(x1/2);%定义y1。
3、命令行键入:plot(x1,y1,'DisplayName','sin(x/2)')%画图。
4、命令行键入:hold on%保持。
5、命令行键入:x2 = [0 1 2 3 4 5];y2 = [0.2 0.3 0.6 1 0.7 0.6];%定义x2,y2。
6、命令行键入:scatter(x2,y2,'fille蟠校盯昂d','DisplayName','2016')%画散点图。
7、命令行键入:legend%调用 legend 命令创建图例
8、命令行键入:x3 = [0 1 2 3 4 5];y3 = [0.1 0.4 0.6 0.9 0.8 0.7];%定义x3,y3。
9、命令行键入:scatter(x3,y3,'fille蟠校盯昂d','DisplayName','2017')%画散点图,并给出标签。
10、命令行键入:drawnow%更新图
11、命令行键入:hold off%停止保持。