楼主: ReneeBK
2749 20

Matlab编程100例 [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4897份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49635 个
通用积分
55.6937
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2015-12-18 08:09:29 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
  1. 实例1:三角函数曲线(1)

  2. function shili01
  3. h0=figure('toolbar','none',...
  4.     'position',[198 56 350 300],...
  5.     'name','实例01');
  6. h1=axes('parent',h0,...
  7.    'visible','off');
  8. x=-pi:0.05:pi;
  9. y=sin(x);
  10. plot(x,y);
  11. xlabel('自变量X');
  12. ylabel('函数值Y');
  13. title('SIN( )函数曲线');
  14. grid on
复制代码


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB编程 MATLAB atlab matla Mat function position visible figure parent

沙发
ReneeBK 发表于 2015-12-18 08:10:59

实例2:三角函数曲线(2)

  1. 实例2:三角函数曲线(2)

  2. function shili02
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 350],...
  5.     'name','实例02');
  6. x=-pi:0.05:pi;
  7. y=sin(x)+cos(x);
  8. plot(x,y,'-*r','linewidth',1);
  9. grid on
  10. xlabel('自变量X');
  11. ylabel('函数值Y');
  12. title('三角函数');
复制代码

藤椅
ReneeBK 发表于 2015-12-18 08:11:45

实例3:图形的叠加

  1. 实例3:图形的叠加

  2. function shili03
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 350],...
  5.     'name','实例03');
  6. x=-pi:0.05:pi;
  7. y1=sin(x);
  8. y2=cos(x);
  9. plot(x,y1,...
  10.     '-*r',...
  11.     x,y2,...
  12.     '--og');
  13. grid on
  14. xlabel('自变量X');
  15. ylabel('函数值Y');
  16. title('三角函数');
复制代码

板凳
ReneeBK 发表于 2015-12-18 08:49:26
  1. 实例4:双y轴图形的绘制

  2. function shili04
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 250],...
  5.     'name','实例04');
  6. x=0:900;a=1000;b=0.005;
  7. y1=2*x;
  8. y2=cos(b*x);
  9. [haxes,hline1,hline2]=plotyy(x,y1,x,y2,'semilogy','plot');
  10. axes(haxes(1))
  11. ylabel('semilog plot');
  12. axes(haxes(2))
  13. ylabel('linear plot');
复制代码

报纸
ReneeBK 发表于 2015-12-18 08:49:57
  1. 实例5:单个轴窗口显示多个图形

  2. function shili05
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 250],...
  5.     'name','实例05');
  6. t=0:pi/10:2*pi;
  7. [x,y]=meshgrid(t);
  8. subplot(2,2,1)
  9. plot(sin(t),cos(t))
  10. axis equal

  11. subplot(2,2,2)
  12. z=sin(x)-cos(y);
  13. plot(t,z)
  14. axis([0 2*pi -2 2])

  15. subplot(2,2,3)
  16. h=sin(x)+cos(y);
  17. plot(t,h)
  18. axis([0 2*pi -2 2])

  19. subplot(2,2,4)
  20. g=(sin(x).^2)-(cos(y).^2);
  21. plot(t,g)
  22. axis([0 2*pi -1 1])
复制代码

地板
ReneeBK 发表于 2015-12-18 08:50:22
  1. 实例6:图形标注

  2. function shili06
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 400],...
  5.     'name','实例06');
  6. t=0:pi/10:2*pi;
  7. h=plot(t,sin(t));
  8. xlabel('t=0到2\pi','fontsize',16);
  9. ylabel('sin(t)','fontsize',16);
  10. title('\it{从 0to2\pi 的正弦曲线}','fontsize',16)
  11. x=get(h,'xdata');
  12. y=get(h,'ydata');
  13. imin=find(min(y)==y);
  14. imax=find(max(y)==y);
  15. text(x(imin),y(imin),...
  16.     ['\leftarrow最小值=',num2str(y(imin))],...
  17.     'fontsize',16)
  18. text(x(imax),y(imax),...
  19.     ['\leftarrow最大值=',num2str(y(imax))],...
  20.     'fontsize',16)
复制代码

7
ReneeBK 发表于 2015-12-18 08:50:49
  1. 实例7:条形图形

  2. function shili07
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 350],...
  5.     'name','实例07');
  6. tiao1=[562 548 224 545 41 445 745 512];
  7. tiao2=[47 48 57 58 54 52 65 48];
  8. t=0:7;
  9. bar(t,tiao1)
  10. xlabel('X轴');
  11. ylabel('TIAO1值');
  12. h1=gca;
  13. h2=axes('position',get(h1,'position'));
  14. plot(t,tiao2,'linewidth',3)
  15. set(h2,'yaxislocation','right','color','none','xticklabel',[])
复制代码

8
ReneeBK 发表于 2015-12-18 08:52:13
  1. 实例8:区域图形

  2. function shili08
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 250],...
  5.     'name','实例08');
  6. x=91:95;
  7. profits1=[88 75 84 93 77];
  8. profits2=[51 64 54 56 68];
  9. profits3=[42 54 34 25 24];
  10. profits4=[26 38 18 15 4];
  11. area(x,profits1,'facecolor',[0.5 0.9 0.6],...
  12.     'edgecolor','b',...
  13.     'linewidth',3)
  14. hold on
  15. area(x,profits2,'facecolor',[0.9 0.85 0.7],...
  16.     'edgecolor','y',...
  17.     'linewidth',3)
  18. hold on
  19. area(x,profits3,'facecolor',[0.3 0.6 0.7],...
  20.     'edgecolor','r',...
  21.     'linewidth',3)
  22. hold on
  23. area(x,profits4,'facecolor',[0.6 0.5 0.9],...
  24.     'edgecolor','m',...
  25.     'linewidth',3)
  26. hold off
  27. set(gca,'xtick',[91:95])
  28. set(gca,'layer','top')
  29. gtext('\leftarrow第一季度销量')
  30. gtext('\leftarrow第二季度销量')
  31. gtext('\leftarrow第三季度销量')
  32. gtext('\leftarrow第四季度销量')
  33. xlabel('年','fontsize',16);
  34. ylabel('销售量','fontsize',16);
复制代码

9
ReneeBK 发表于 2015-12-18 08:53:00
  1. 实例9:饼图的绘制

  2. function shili09
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 250],...
  5.     'name','实例09');
  6. t=[54 21 35;
  7.     68 54 35;
  8.     45 25 12;
  9.     48 68 45;
  10.     68 54 69];
  11. x=sum(t);
  12. h=pie(x);
  13. textobjs=findobj(h,'type','text');
  14. str1=get(textobjs,{'string'});
  15. val1=get(textobjs,{'extent'});
  16. oldext=cat(1,val1{:});
  17. names={'商品一:';'商品二:';'商品三:'};
  18. str2=strcat(names,str1);
  19. set(textobjs,{'string'},str2)
  20. val2=get(textobjs,{'extent'});
  21. newext=cat(1,val2{:});
  22. offset=sign(oldext(:,1)).*(newext(:,3)-oldext(:,3))/2;
  23. pos=get(textobjs,{'position'});
  24. textpos=cat(1,pos{:});
  25. textpos(:,1)=textpos(:,1)+offset;
  26. set(textobjs,{'position'},num2cell(textpos,[3,2]))
复制代码

10
ReneeBK 发表于 2015-12-18 08:53:34
  1. 实例10:阶梯图

  2. function shili10
  3. h0=figure('toolbar','none',...
  4.     'position',[200 150 450 400],...
  5.     'name','实例10');
  6. a=0.01;
  7. b=0.5;
  8. t=0:10;
  9. f=exp(-a*t).*sin(b*t);
  10. stairs(t,f)
  11. hold on
  12. plot(t,f,':*')
  13. hold off
  14. glabel='函数e^{-(\alpha*t)}sin\beta*t的阶梯图';
  15. gtext(glabel,'fontsize',16)
  16. xlabel('t=0:10','fontsize',16)
  17. axis([0 10 -1.2 1.2])
复制代码

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-25 17:57