MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线MATLAB之其他形式的二维曲线

  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之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

 t=0:pi/100:2*pi;
>> r=1-sin(t);%根据题目要求
>> subplot(1,2,1);
>> polar(t,r)%输出在t,r关系下的图像关系
>> subplot(1,2,2)
>> t1=t-pi/2;%图像逆时针旋转90°,若为加号,则为顺时针旋转。
>> r1=1-sin(t1);
>> polar(t,r1)%输出关系图像

 

绘制分组条形图

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

> y=[1,2,3,4,5;1,2,1,2,1;5,4,3,2,1]

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之其他形式的二维曲线

MATLAB之其他形式的二维曲线MATLAB之其他形式的二维曲线

x=[2015,2016,2017];
y=[68,80,115,98,102,;75,88,102,99,110;91,86,125,105,115];
bar(x,y)%默认为蔟状分组
title('group')
MATLAB之其他形式的二维曲线MATLAB之其他形式的二维曲线

绘制服从高斯分布的直方图

MATLAB之其他形式的二维曲线

> 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之其他形式的二维曲线

MATLAB之其他形式的二维曲线

x缺省时,默认为20

回执高斯分布在极坐标下的直方图显示

MATLAB之其他形式的二维曲线

 y=randn(500,1);%随机函数生成列向量
>> theta=y*pi;%将y转为弧度值,付给theta
>> rose(theta)%调用rose函数,绘制图形
>> title('在极坐标下的直方图')
>>  y=randn(500,1);
theta=y*pi;
rose(theta)
title('在极坐标下的直方图')
 

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

 score=[5,17,23,9,4];
ex=[0,0,0,0,1];
pie(score,ex)
legend('优秀','良好','中等','及格','不及格','location','eastoutside')
title('成绩统计分析')
 score=[5,17,23,9,4];%生成向量score,存储各个成绩段的人数
ex=[0,0,0,0,1];%向量ex生成图形控制值,第五个元素为1,其余为0
pie(score,ex)%调用pie函数,绘制图形
legend('优秀','良好','中等','及格','不及格','location','eastoutside')
%添加图例,观察图形,按图里的顺序从正上方开始围绕圆点逆时针排列扇形,第五个扇形从饼图中分离
>> title('成绩统计分析')
location用于指定图形位置eastoutside表示图例放在右边回执图形的外侧,若无指定图例位置,图形会放在饼图里面会遮挡一部分图形

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

> 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')%rd红色菱形,filled填满这个区间里面的所有图形

 

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

MATLAB之其他形式的二维曲线

>> 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之其他形式的二维曲线