MATLAB 二维曲线(常用)

MATLAB 二维曲线(常用)

eg:绘制1/x的直角线性坐标图和三种对数坐标图。

x=0:0.1:10;
y=1./x;
subplot(2,2,1);
plot(x,y)
title('plot(x,y)');
subplot(2,2,2);
semilogx(x,y)
title('semilogx(x,y)');
grid on
subplot(2,2,3);
semilogy(x,y)
title('semilogy(x,y)');
grid on
subplot(2,2,4);
loglog(x,y)
title('loglog(x,y)');
grid on

MATLAB 二维曲线(常用)_第1张图片

极坐标图 polar(theta,rho,选项)

theta:极角 rho:极径

eg:按极坐标方程p=1-sin角 绘制心性曲线。

t=0:pi/100:2*pi;
r=1-sin(t);
subplot(1,2,1)
polar(t,r)
subplot(1,2,2)
t1=t-pi/2;
r1=1-sin(t1);
polar(t,r1)

MATLAB 二维曲线(常用)_第2张图片

eg:绘制分组条形图

y=[1,2,3,4,5;1,2,1,2,1;5,4,3,2,1];
subplot(1,2,1)
bar(y)
title('Group')
subplot(1,2,2)
bar(y,'stacked')
title('Stack')

MATLAB 二维曲线(常用)_第3张图片

eg:绘制服从高斯分布的直方图。hist

y=randn(500,1);
subplot(2,1,1);
hist(y);
title('高斯分布图');
subplot(2,1,2);
x=-3:0.2:3;
hist(y,x);
title('指定区间中心点的直方图')')

MATLAB 二维曲线(常用)_第4张图片

rose函数 rose(theta,x)

eg:绘制高斯分布数据在极坐标下的直方图。

y=randn(500,1);
theta=y*pi;
rose(theta)
title('在极坐标下的直方图')

MATLAB 二维曲线(常用)_第5张图片

pie函数 pie(x,explode)

eg:某次考试优秀,良好,中等,及格,不及格的人数分别为:5,17,23,9,4,试用扇形统计图作成绩统计分析。

score=[5,17,23,9,4];
ex=[0,0,0,0,1];
pie(score,ex)
legend('优秀','良好','中等','及格','不及格','location','eastoutside')

MATLAB 二维曲线(常用)_第6张图片

scatter函数 scatter(x,y,选项,‘filled’)

eg:
MATLAB 二维曲线(常用)_第7张图片

t=0:pi/50:2*pi;
x=16*sin(t).^3;
y=13*cos(t)-5*cos(2*t)-2*cos(3*t)-cos(4*t);
scatter(x,y,'rd','filled')

MATLAB 二维曲线(常用)_第8张图片

quiver函数 quiver(x,y,u,v)

eg:已知向量A,B,求A+B,并用矢量图表示。

A=[4,5];
B=[-10,0];
C=A+B;
hold on;
quiver(0,0,A(1),A(2));
quiver(0,0,B(1),B(2));
quiver(0,0,C(1),C(2));
text(A(1),A(2),'A');
text(B(1),B(2),'B');
text(C(1),C(2),'C');
axis([-12,6,-1,6])
grid on

MATLAB 二维曲线(常用)_第9张图片

你可能感兴趣的:(matlab,矩阵,线性代数)