Sparse Arrays(6/35) Example a-speye(4) full(a) a= ans (1,1) 1 1 0 0 0 (2,2) 1 0 1 00 (3,3) 1 0 01 0 (4,4) 1 00 01 r=sprand(s)has the same ¥[xyz]=find(a) sparsity structure as s X-y=Z- sprand(a) 1 1 1 ans 2 2 1 (1,1) 0.1341 3 3 1 (2,2) 0.0653 4 4 1 (3,3) 0.3751 细月济大学 (4,4) 0.3735 TONGJI UNIVERSITY
Sparse Arrays(6/35) Example ✓ a=speye(4) a = (1,1) 1 (2,2) 1 (3,3) 1 (4,4) 1 ✓ r = sprand(s) has the same sparsity structure as s ✓ sprand(a) ans = (1,1) 0.1341 (2,2) 0.0653 (3,3) 0.3751 (4,4) 0.3735 ✓ full(a) ans = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 ✓ [x y z]=find(a) x = 1 2 3 4 y = 1 2 3 4 z = 1 1 1 1
Cell Arrays(7/35) A cell array is a special MATLAB array whose elements are cells,containers that can hold other MATLAB arrays. In programming terms,each element of a cell is a pointer to another data structure,and those structure can be of different types. For example,one cell ofa cell array might contain an array 3 of real numbers,another an array of strings,and yet another an array of complex numbers. @日济大学 AW TONGJI UNIVERSITY
Cell Arrays(7/35) A cell array is a special MATLAB array whose elements are cells, containers that can hold other MATLAB arrays. In programming terms, each element of a cell is a pointer to another data structure, and those structure can be of different types. For example, one cell of a cell array might contain an array of real numbers, another an array of strings, and yet another an array of complex numbers
Cell Arrays(8/35) Cell 1,1 Cell 1,2 「1 3 -7 3 4 'This is a text 9 -8 7 string!' Cell 2,1 Cell 2,2 「3+4i -5 -i10 3-i4 0 CPHAW 同你大学 TONGJI UNIVERSITY
Cell Arrays(8/35) Cell 1,1 Cell 1,2 ‘This is a text string!’ Cell 2,1 Cell 2,2 [] 1 3 7 2 3 4 9 8 7 − − 3 4 5 10 3 4 i i i + − − −
Cell Arrays(9/35) -7 2 3 4 9 -8 > Cell 1,1Cell 1,2 G 0 "This is a text string! Cell 2,1Cell 2,2 Q ○ 「3+4i-5 -103-4 Each element of a cell array holds a pointer to another data structure,and different cells in the same cell array can point to AW different types of data structures. 翻日济大学 TONGJI UNIVERSITY
Cell Arrays(9/35) Each element of a cell array holds a pointer to another data structure, and different cells in the same cell array can point to different types of data structures
Cell Arrays(10/35) ▣creating cell arrays √Two ways By using assignment statements. By preallocatinga cell array using the cell function Using assignment statements ■Content indexing a{1,1}=[13-7;206;051]; a{1,2)=This is a text string.'; a{2,1}=[3+4*i-5;-10*i3-4*i]: a{2,2}=[] ■Cell indexing a(1,1)={[13-7;206,051]}; a(1,2)={"This is a text string.); a(2,1)={[3+4*i-5;-10*i3-4*i]}; a(2,2)={[]}; @月协大学 TONGJI UNIVERSITY
Cell Arrays(10/35) creating cell arrays ✓ Two ways ◼ By using assignment statements. ◼ By preallocating a cell array using the cell function ✓ Using assignment statements ◼ Content indexing a{1,1}=[1 3 -7; 2 0 6;0 5 1]; a{1,2}='This is a text string.'; a{2,1}=[3+4*i -5; -10*i 3-4*i]; a{2,2}=[ ]; ◼ Cell indexing a(1,1)={[1 3 -7; 2 0 6;0 5 1]}; a(1,2)={'This is a text string.'}; a(2,1)={[3+4*i -5; -10*i 3-4*i]}; a(2,2)={[ ]};