标签:
一、常用命令:普通的如cd、ls和linux下一样
二、数据类型
1 >> String = ‘hello world‘ 2 3 String = 4 5 hello world 6 7 >> size(String) 8 9 ans = 10 11 1 11 //1行,11个字节 12 >> u = abs(String) 13 14 u = 15 16 104 101 108 108 111 32 119 111 114 108 100 17 18 >> U = String(0:5) 19 Subscript indices must either be real positive integers or logicals. //出错,不是从0开始的 20 21 >> U = String(1:5) 22 23 U = 24 25 hello 26 27 >> U = String(5:-1:1) //和python不同,间隔放在中间 28 29 U = 30 31 olleh
4、sturct: 句法形式:StrArray = struct(‘field1‘, var1, ‘field2‘, var2, ..., ‘fieldn‘, varn);
1 >> Student.Name = ‘Sam‘; 2 >> Student.Grade = 6; 3 >> Student.Subject = {‘Chinese‘, ‘Math‘, ‘English‘}; 4 >> Student.Result = {99, 98, 97}; 5 >> Student 6 7 Student = 8 9 Name: ‘Sam‘ 10 Grade: 6 11 Subject: {‘Chinese‘ ‘Math‘ ‘English‘} 12 Result: {[99] [98] [97]}
1 >> StrArray = struct(‘Day‘, {‘Thursday‘, ‘Friday‘}, ‘Time‘, {‘15:00‘, ‘9:00‘}) 2 3 StrArray = 4 5 1x2 struct array with fields: 6 7 Day 8 Time 9 10 >> StrArray(1) 11 12 ans = 13 14 Day: ‘Thursday‘ 15 Time: ‘15:00‘ 16 17 >> StrArray(2) 18 19 ans = 20 21 Day: ‘Friday‘ 22 Time: ‘9:00‘
5、单元数组类型cell:可以把不同类型的数据归并到一个数组中
>> C = {‘x‘, [1; 3; 6]; 10, pi} C = ‘x‘ [3x1 double] [10] [3.141592653589793] >> whos Name Size Bytes Class Attributes C 2x2 490 cell
标签:
原文地址:http://www.cnblogs.com/dylqt/p/4824171.html