手机版
你好,游客 登录 注册
背景:
阅读新闻

Matlab数据处理快速学习教程

[日期:2012-07-02] 来源:Linux社区  作者:esricd [字体:大 中 小]

========================PlottingData========================

 

>>t=[0:0.01:0.98];

>> y1=sin(2*pi*4*t);

>> plot(t,y1)


>> hold on;%plotnew figure on the old ones

>> y2=cos(2*pi*4*t);

>> plot(t,y2,'r')

 

>> xlabel('time')
>> ylabel('value')
>> legend('sin','cos')
>> title('my plot')
>> print -dpng 'myplot.png'%save as a file in default catalog

>> close



%分别显示两幅图像

>> figure(1);plot(t,y1);

>> figure(2);plot(t,y2)
>> 

%一幅图中显示两个subplot

 figure
subplot(1,2,1);plot(t,y1)
subplot(1,2,2);plot(t,y2)
axis([0.5 1 -1 1])


 

  A=magic(5)

imagesc(A)



>>imagesc(A),colorbar,colormap gray;

 

 

 

 ========================for if while statements========================
  1. > v=zeros(10,1)  
  2. for i=1:10  
  3. v(i)=2^i;  
  4. end  
  5. v  
v =


     0
     0
     0
     0
     0
     0
     0
     0
     0
     0




v =


           2
           4
           8
          16
          32
          64
         128
         256
         512
        1024
  1. indices=1:10;  
  2. indices  
  3. for i=indices, disp(i);  
  4. end  
  5. i=1;  
  6. while i<=5,  
  7. v(i)=100;  
  8. i=i+1;  
  9. end;  
  10. v  
  11. i=1;  
  12. while true,  
  13. v(i)=999;  
  14. i=i+1;  
  15. if i==6,  
  16. break;  
  17. end  
  18. end  
  19. v  
  20. v(1)=2;  
  21. if v(1)==1,  
  22. disp('The value is one');  
  23. else if v(1)==2,  
  24. disp('The value is two');  
  25. else  
  26. disp('The value is neither one or two');  
  27. end  
  28. end  
linux
相关资讯       Matlab  Matlab教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款