x = 0:pi/10:2*pi;
y = sin(x);
plot(x,y);
x = 0:pi/10:2*pi;
y = sin(x);
plot(x,y,'LineStyle','-.'); % 断点线
其它可选值:https://cn.mathworks.com/help/matlab/ref/plot.html?s_tid=gn_loc_drop#input_argument_namevalue_d119e766669
x = 0:pi/10:2*pi;
y = sin(x);
plot(x,y,'LineWidth',2); %线宽为2,默认为0.5
其它可选值:https://cn.mathworks.com/help/matlab/ref/plot.html?s_tid=gn_loc_drop#input_argument_namevalue_d119e766777
x = 0:pi/10:2*pi;
y = sin(x);
plot(x,y,'Color','r'); %红色线
其它可选值:https://cn.mathworks.com/help/matlab/ref/plot.html?s_tid=gn_loc_drop#input_argument_namevalue_d119e766499
x = 0:pi/10:2*pi;
y = sin(x);
plot(x,y,'Marker','s'); %方块点
其它可选值:https://cn.mathworks.com/help/matlab/ref/plot.html?s_tid=gn_loc_drop#input_argument_namevalue_d119e766805
x = 0:pi/10:2*pi;
y = sin(x);
plot(x,y);
title('sin demo');
xlabel('x axis');
ylabel('y axis');
绘制两条曲线
x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = cos(x);
figure
plot(x,y1);
hold on
plot(x,y2)
legend('sin','cos')
hold off
一次绘制一个点
x = 0:pi/10:2*pi;
y = sin(x);
figure
for i=1:length(x)
plot(x(i),y(i),'Marker', 's')
hold on
end
hold off
x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = cos(y);
y3 = x;
y4 = x.^2;
y5 = 1./(x+1);
y6 = exp(x);
figure
subplot(2,3,1) %2x3=6张图,编号从1到6,从上到下,从左到右
plot(x,y1)
subplot(2,3,2)
plot(x,y2)
subplot(2,3,3)
plot(x,y3)
subplot(2,3,4)
plot(x,y4)
subplot(2,3,5)
plot(x,y5)
subplot(2,3,6)
plot(x,y6)