markersize,用圆圈画每个点,离散的点之间不连线,不用圈圈的话plot默认把每个离散点用直线连起来
linewidth,线宽
MATLAB是不可以画出连续函数的图像的,只能用一群离散点(划分更细)去在视觉上像连续的。
x1=(0:12)*pi/6;y1=cos(3*x1);
x2=(0:360)*pi/180;y2=cos(3*x2);
figure(1)
subplot(221);plot(x1,y1,'o','markersize',3);xlim([0 2*pi]);
subplot(222);plot(x1,y1,'linewidth',2);xlim([0 2*pi]);
subplot(223);plot(x2,y2,'o','markersize',3);xlim([0 2*pi]);
subplot(224);plot(x2,y2,'linewidth',2);xlim([0 2*pi]);
x=-pi/2:.01:pi/2;
y=x+sin(x)+exp(x);
plot(x,y,'ro');%用红圈表示离散的函数取值
grid on
legend('y=x+sin(x)+exp(x)')
x=-pi/2:.01:pi/2;
y=x+sin(x)+exp(x);
plot(y,'ro');%用红圈表示离散的函数取值
xlim([1 length(y)])
grid on
legend('y=x+sin(x)+exp(x)')
x=cos(-pi:pi/10:pi)+i*sin(-pi:pi/10:pi);
plot(x);%横轴实部,纵轴虚部
grid on
x=magic(20);
plot(x);%横轴是行,纵轴是列
grid on
x=2;
y=0.4;
bluecircle=cos(-pi:pi/20:pi)+i*sin(-pi:pi/20:pi)+(i*y-x);
blackcircle=cos(-pi:pi/20:pi)+i*sin(-pi:pi/20:pi)+(i*y);
redcircle=cos(-pi:pi/20:pi)+i*sin(-pi:pi/20:pi)+(i*y+x);
yellowcircle=cos(-pi:pi/20:pi)+i*sin(-pi:pi/20:pi)+(-i*y-x/2);
greencircle=cos(-pi:pi/20:pi)+i*sin(-pi:pi/20:pi)+(-i*y+x/2);
plot(bluecircle,'linewidth',5);hold on
plot(blackcircle,'k','linewidth',5);hold on
plot(redcircle,'r','linewidth',5);hold on
plot(yellowcircle,'y','linewidth',5);hold on
plot(greencircle,'g','linewidth',5);
markeredgecolor
markerfacecolor
x=-pi:pi/10:pi;% 步长为pi/10,共21个点
y=tan(sin(x))-sin(tan(x));%可以说是很奇怪的函数了
plot(x,y,'--rs','linewidth',2,'markeredgecolor','k','markerfacecolor','g','markersize',10)
plot画包络
t=(0:pi/100:pi)';%列向量
y1=sin(t)*[1 -1];%矩阵相乘,y1是矩阵
y2=sin(t).*sin(9*t);%点乘,列向量
t3=pi*(0:9)/9;%行向量
y3=sin(t3).*sin(9*t3);%行向量
plot(t,y1,'r:',t,y2,'b',t3,y3,'ko')
axis([0 pi -1 1])
x=-pi:pi/10:pi;
y=[sin(x);sin(x+3);sin(x+5)];
z=[cos(x);cos(x+3);cos(x+5)];
plot(x,y,'r:*',x,z,'g-.v')
grid on