简单绘图部分:
%简单绘图
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; %显示网格
%联合作图
x = 0:pi/100:2*pi;
y1 = sin(2*x);
y2 = 2*cos(2*x);
plot(x,y1,x,y2)


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
legend('string1','string2',...,pos) %图例,pos值用来指定图例位置
legend off %去除多余的图例
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;
该文展示了如何使用MATLAB进行基础的图形绘制,包括单个函数曲线的绘制,如y=x^2-10*x+15,以及多个函数的联合作图,如sin(2x)和2*cos(2x)。同时,文章还涉及了图例的添加和位置调整,以及使用不同颜色和线型区分不同的函数曲线。
1238

被折叠的 条评论
为什么被折叠?



