MATLAB学习笔记

MATLAB的数组访问好鬼畜啊,全下标是符合各种编程语言的先行再列,然后单下标(索引值)居然是先列再行==绝了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
>> A=[1 2 3 4;5 6 7 8]

A =

     1     2     3     4
     5     6     7     8

>> A(1,3)

ans =

     3

>> A(3)

ans =

     2

元胞数组的创建于连接

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
>> a(1,1)={'mdzz'}

a = 

    'mdzz'

>> a(1,2)={ones(3)}

a = 

    'mdzz'    [3x3 double]

>> a{2,1}='qwq'

a = 

    'mdzz'    [3x3 double]
    'qwq'               []

>> a{2,2}='matlab'

a = 

    'mdzz'    [3x3 double]
    'qwq'     'matlab'    

>> b=a

b = 

    'mdzz'    [3x3 double]
    'qwq'     'matlab'    

>> c=[a b]

c = 

    'mdzz'    [3x3 double]    'mdzz'    [3x3 double]
    'qwq'     'matlab'        'qwq'     'matlab'    

>> c=[a;b]

c = 

    'mdzz'    [3x3 double]
    'qwq'     'matlab'    
    'mdzz'    [3x3 double]
    'qwq'     'matlab'    
    
  >> b=cell(2,3)

b = 

    []    []    []
    []    []    []
Licensed under CC BY-NC-SA 4.0
Built with Hugo
主题 StackJimmy 设计