简单绘图部分:
%简单绘图
x=0:1:10;
y=x.^2-10*x+15; %n次方中注意小圆点
plot(x,y);
title('Plot of y=x^2+10*x+15');
xlabel('x');
ylabel('y');
grid on; %显示网格
![](https://i-blog.csdnimg.cn/blog_migrate/0bd00d6dcf4359d130b55722047cc6f6.png)
%联合作图
x = 0:pi/100:2*pi;
y1 = sin(2*x);
y2 = 2*cos(2*x);
plot(x,y1,x,y2)
![](https://i-blog.csdnimg.cn/blog_migrate/7a0734cc8b58529e6ad9d4faf3bf9462.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e79560007396d5098b235bdf84ce9f24.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4e5b39e19ed529d9ca86a8fbc0b64352.png)
x = 0:pi/100:2*pi;
y1 = sin(2*x);
y2 = 2*cos(2*x);
plot(x,y1,'ro',x,y2,'b--');% y1-red+circle; y2-blue+dashed
![](https://i-blog.csdnimg.cn/blog_migrate/f34d57449670a9fa99737d516205f3f2.png)
legend('string1','string2',...,pos) %图例,pos值用来指定图例位置
legend off %去除多余的图例
![](https://i-blog.csdnimg.cn/blog_migrate/ac78731f3223eb056b9a8873312328aa.png)
x = 0:pi/100:2*pi;
y1 = sin(2*x);
y2 = 2*cos(2*x);
plot(x,y1,'r-',x,y2,'bx');
title('Plot of y=sin2x and its derivative');
xlabel('x');
ylabel('y');
legend('y1=sin2x','y2=2cos2x');
grid on;
![](https://i-blog.csdnimg.cn/blog_migrate/f081d769f86ad8474152b616c44c664f.png)