Advertisement
hackerboxes

matlab 学习笔记1

Sep 9th, 2013
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 1.88 KB | None | 0 0
  1. matlab学习笔记
  2. 1.fullfile(路径1,路径2,文件名); // 创建全路径文件
  3. // 如ok_file=fullfile("c:","app","ok.m");最终为C:\app\ok.m
  4. 2.fopen('./stations/OVL_stations_o3.txt')   //打开文件,并返回指针
  5. 如:a=fopen('./stations/OVL_stations_o3.txt')
  6. str=fctl(a);   //读取第一行数据,并赋值给str
  7.  
  8. 3.分隔字符串用regexp函数
  9. 如:
  10. a1=regexp(str,';');   // 以分号分隔字符串,返回的数据为一维数组
  11.  
  12.  
  13. 4.~=表示不等号
  14. 如:str~=-1
  15.  
  16. 5.转换函数
  17. str2double
  18. isstr
  19. 6.结构体定义
  20. struct('nr',数据1,'type',数据2);
  21. 如:
  22. d=struct('n',8884,'b',00999);
  23. d.n
  24. d.dbfile='c:\dbfile.mat';
  25. d.have_db = true;
  26.  
  27. 6.数组结构体
  28. str_info=[];
  29. str_info=[str_info:struct('nr':)]
  30.  
  31. 7.clear   // 清除工作空间数据
  32. 8.load  用来加载mat文件数据
  33. load('c:\test.mat');
  34. 9.显示矩阵的第2
  35. data(:,2)
  36.  
  37. 10.sort对数据进行排序
  38.  
  39. sort(ok(:,2),1,'ascend')   // ok矩阵中的第2行数据升序排列
  40. sort(ok(:,2),1,'descend')                         //ok矩阵中的第2行数据升序排列
  41.  
  42.  
  43.  
  44. 11. datestr( pol_date(1), 'yyyy-mm-dd' ) 日期转换为字符串
  45. 12.isempty   // 表示数据是否为空
  46. 13.length    // 数据长度,一般是一维数组
  47.  
  48. 14.生成序列数据
  49. 116:1:118  // 表示生成的数据为开始为116,步长为1,结束为118
  50. 打印结构为:
  51. ans =
  52.  
  53.    116   117   118
  54.    
  55. 15.strcmp  //比较数据
  56.  
  57. 16.列表的定义
  58. 如:
  59. a={
  60.     'list-1','list-2',
  61.     'list-3','list-4'}
  62.    
  63.    
  64.    
  65. 17.addpath ./lib
  66.  
  67. 18.function定义
  68. 如:
  69. function cnf=read_cnf()
  70. c=struct();
  71. c.file='c:\config.txt';
  72. cnf=c;
  73.  
  74. function [a]=read_cnf()
  75. a=[1:1:23];
  76. end
  77.  
  78. 19.find
  79. doc find   // 查看帮助文档
  80. 如:
  81. a=magic(4)   // 创建magic
  82. find(a>10) //返回数据值
  83. find(a==16-1)  //返回此数据的个数(列数)
  84.  
  85. 20.exp  e的几次幂
  86.  
  87. e=exp(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement