Download presentation
Presentation is loading. Please wait.
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.
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
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
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.