MATLAB常用二维图

线图

一张图

clc,clear
x = 0:1:30;
y = sin(x);
plot(x,y);  %若(x,y,'LineWidth',2)可变粗
xlabel("横坐标轴");
ylabel("纵轴标题");
%grid on     %显示网格
%axis([0 20 -1.5 1.5])   %设置横纵坐标范围

多张图

clc,clear
x = 0:0.01:30;
y1 = sin(x);
y2 = cos(x);
plot(x,y1,x,y2);

条形图

bar函数创建崔志条形图
bath函数用来创建水平条形图

clc,clear
t = -3:0.5:3;
p = exp(-t.*t);
bar(t,p);
barh(t,p);

极坐标图

polarplot函数用来绘制极坐标图

clc,clear
theta = 0:0.01:2*pi;
%abs求绝对值或复数的模
radi = abs(sin(7*theta).*cos(10*theta));
polarplot(theta,radi);  %括号内是弧度和半径

散点图

scatter函数用来绘制x和y值的散点图

posted @ 2022-04-18 11:01  又一岁荣枯  阅读(124)  评论(0编辑  收藏  举报