matlab基础操作(八)

 

46.绘制椭圆,长轴为3.25,短轴为1.15

    >> x=1.15*cos(t);y=3.25*sin(t);%y为长轴,x为短轴

    >> subplot(2,2,1);plot(x,y);

    >> axis off%不显示坐标轴

    >> title('axis off')

    >> subplot(2,2,2);plot(x,y);

    >> axis image;%纵、横坐标等长刻度,坐标框紧贴数据范围

    >> title('axis image')

    >> subplot(2,2,3);plot(x,y);

    >> axis equal;%纵、横坐标等长刻度

    >> subplot(2,2,4);plot(x,y);

    >> axis square;%产生方形坐标系

    >> title('axis square');

 

47.分格线与grid指令

    grid on(画出分格线);

    grid off(不画分格线),缺省设置;

    >> t=6*pi*(0:100)/100;

    >> y=1-exp(-0.3*t).*cos(0.7*t);

    >> tt=t(find(abs(y-1)>0.05));

    >> ts=max(tt);

    >> plot(t,y,'r-');

    >> grid on;

    >> axis([0,6*pi,0.6,max(y)]);

    >> title('y=1-exp(-\alpha*t)*cos(\omega*t)');

    >> hold on;

    >> plot(ts,0.95,'bo');

    >> hold off;

    >> set(gca,'xtick',[2*pi,4*pi,6*pi],'ytick',[0.95,1,1.05,max(y)]);

    >> grid on;

 

48.在正弦曲线上标注特殊值

    >> t=(0:100)/100*2*pi;

    >> y=sin(t);

    >> plot(t,y);

    >> text(3*pi/4,sin(3*pi/4),'\fontsize{16}\leftarrowsin(t)=.707');

    >> text(pi,sin(pi),'\fontsize{16}\leftarrowsin(t)=0');

    >> text(5*pi/4,sin(5*pi/4),'\fontsize{16}sin(t)=-.707\rightarrow','HorizontalAlignment','right')

%'HorizontalAlignment','right'设置图形标识为水平右对齐

 

    >> t=0:900;

    >> plot(t,0.25*exp(-0.005*t));

    >> title('\fontsize{16}\itAe^{\alphat}');

    >> text(300,.25*exp(-0.005*300),'\fontsize{14}\leftarrow0.25\ite^-0.005\itt_at\itt=300');

 

49.特殊图形(直方图(柱形图)bar)

    >> x=-2.9:0.2:2.9;

    >> bar(x,exp(-x.*x),'r');

 

例如:北京市从业人员统计

 

    (累计式直方图一(竖着))

    >> year=[1990 1995 2000];

    >> people=[90.7 281.6 254.8;70.6 271 323.7;73.9 214.6 326.5];

    >> bar(year,people,'stack');

    >> legend('\fontsize{6}第一产业','\fontsize{6}第二产业','\fontsize{6}第三产业');

 

    (累计式直方图二(横着))

    >> barh(year,people,'stack');

    >> legend('\fontsize{6}第一产业','\fontsize{6}第二产业','\fontsize{6}第三产业');

 

    (分组式直方图一(竖着))

    >> bar(year,people,'group');%分组式直方图

    >> legend('\fontsize{6}第一产业','\fontsize{6}第二产业','\fontsize{6}第三产业');

 

    (分组式直方图二(横着))

    >> barh(year,people,'group');

    >> legend('\fontsize{6}第一产业','\fontsize{6}第二产业','\fontsize{6}第三产业');

 

50.饼图指令pie

 

饼图指令pie用来表示各元素占总和的百分数。该指令第二输入变量是与第一变量同长的0-1向量,1使对应扇块突出。

    >> a=[1,1.6,1.2,0.8,2.1];

    >> subplot(1,2,1),pie(a,[1 0 1 0 0]),legend({'1','2','3','4','5'});

    >> subplot(1,2,2),b=int8(a==min(a));

    >> pie3(a,b);

    >> colormap(cool);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值