标签:关系 span 自动 方差 range pre asi 矩阵 方向
1、快捷键:
2、特殊变量:
3、
4、高维数组:
>> %2行,2列,2页 >> x(1:2,1:2,1)=[1 2;3 4]; >> x(1:2,1:2,2)=[5 6;7 8]; >> x x(:,:,1) = 1 2 3 4 x(:,:,2) = 5 6 7 8
5、定义结构体数组:
>> %直接赋值 >> struct1(1).name=‘xiezhh‘; >> struct1(2).name=‘heping‘; >> struct1(1).age=31; >> struct1(2).age=32; >> struct1 struct1 = 1x2 struct array with fields: name age
>> struct2=struct(‘name‘,{‘xiezhh‘,‘helping‘},‘age‘,{31,32}) struct2 = 1x2 struct array with fields: name age >> struct2(1).name ans = xiezhh
6、定义元胞数组
不同类型,不同大小放一个数组里
>> c1={[1 2;3 4],‘xiezhh‘,[5 6 7],‘emmm‘} c1 = [2x2 double] ‘xiezhh‘ [1x3 double] ‘emmm‘
>> c2=cell(2,4) c2 = [] [] [] [] [] [] [] [] >> c2{2,3}=[1 2 3] c2 = [] [] [] [] [] [] [1x3 double] []
>> c1={[1 2;3 4],‘xiezhh‘;[5 6 7],‘emmm‘} c1 = [2x2 double] ‘xiezhh‘ [1x3 double] ‘emmm‘ >> c1(2,2) ans = ‘emmm‘ >> c1{2,2} ans = emmm
7、数组转换
>> a=rand(60,50); >> b=mat2cell(a,[10,20,30],[25,25]) b = [10x25 double] [10x25 double] [20x25 double] [20x25 double] [30x25 double] [30x25 double] >> c=cell2mat(b); >> isequal(a,c) ans = 1
>> c={‘zxc‘,‘xian‘,31;‘sdfbn‘,‘shengzhen‘,26} c = ‘zxc‘ ‘xian‘ [31] ‘sdfbn‘ ‘shengzhen‘ [26] >> fields={‘Name‘,‘Adress‘,‘Age‘}; >> s=cell2struct(c,fields,2) s = 2x1 struct array with fields: Name Adress Age >> cs=struct2cell(s) cs = ‘zxc‘ ‘sdfbn‘ ‘xian‘ ‘shengzhen‘ [ 31] [ 26] >> isequal(c,cs‘) ans = 1
8、
标签:关系 span 自动 方差 range pre asi 矩阵 方向
原文地址:https://www.cnblogs.com/ileanj1998/p/9058515.html