Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 10 Sparse, Cell, & Structure Arrays

Similar presentations


Presentation on theme: "Chapter 10 Sparse, Cell, & Structure Arrays"— Presentation transcript:

1 Chapter 10 Sparse, Cell, & Structure Arrays

2 Sparse Arrays A sparse array (matrix) is a large matrix in which the vast majority of the elements are zero.

3 Sparse Matrix Functions sparse: Converts a full matrix into a sparse matrix. full: Converts a sparse matrix into a full matrix.

4

5 Sparse Array Example Solve the following simultaneous system of equations with sparse matrices: 1.0 X X X X4 = X X X X4 = X X X X4 = X X X X4 = 1.0

6

7 Cell Arrays Array in which each element is a bin which can contain an array. Cells of mixed data types are allowed. Use { } instead of ( ) for selecting & displaying the contents of cells.

8 Creating Cell Arrays C = cell(n) Creates n x n cell array of empty matrices. celldisp(C) Displays the content of cell array C. { } = empty cell

9

10 Example Cell Arrays Result of executing the following script? >>A=ones(3,2); >>B=magic(3); >>C=char(‘Pressure’,’Temp’,’Disp’); >>D=[6+7j, 15]; >>Cel={A, B; C, D}

11 Structure Arrays Arrays composed of structures
Structure Arrays Arrays composed of structures. Each element is given a name (field). Each field may be of different type. Address fields with structure & field separated by period.

12 Structure Functions rmfield >> Remove field n_str=rmfield(str,’field’) fieldnames(S) Returns field names in structure S.

13

14

15

16


Download ppt "Chapter 10 Sparse, Cell, & Structure Arrays"

Similar presentations


Ads by Google