10_cell_main - Cell arrays, Structures, and Structure...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Cell arrays, Structures, and Structure Arrays ENCMP 100 2011 by ECE, UofA Cell arrays and structures Overview New data structures: cell arrays structures structure arrays How these structures are created and how they can be visualized and modified cell , celldisp , and cellplot functions for cell arrays struct , rmfield , and fieldnames functions for structures and structure arrays 2 ENCMP 100 2011 by ECE, UofA Arrays, cell arrays, structures, and structure arrays Cell arrays, structures and structure arrays are convenient to group related variables together e.g., in our case study about fuel consumption instead of storing information about model, MSRP, and fuel economy of different cars in three separate variables, they could be grouped together using a cell array called cars. In contrast to the regular arrays, they allow to group different types of variables model is a string, while fuel economy is a double 3 Cell arrays and structures ENCMP 100 2011 by ECE, UofA Arrays: definition Array is a data type in which individual elements are of the same type (e.g., only doubles, characters). It has one name for the whole data structure; single values are stored in elements identified by numbers (locations in the array). >> MSRP = [20445 19695; 26150 27950] MSRP = 20445 19695 26150 27950 >> MSRP(1,1) ans = 20445 4 Cell arrays and structures ENCMP 100 2011 by ECE, UofA Cell arrays: definition Cell array is a data structure that stores values of different types (e.g., strings and doubles). It has one name for the whole data structure in which individual elements could be of different types; Each element is identified by its number (location in the cell array) 5 Cell arrays and structures ENCMP 100 2011 by ECE, UofA Cell arrays: how to create Cell array are created in a similar way as arrays, but curly braces are used instead of square brackets. for example: lets create a cell array in which one element stores integer, one element stores a character, one element stores an 1D array, and one element stores a string >> cell_row = {113 , '%' , [2, 3, 4] , 'hello world'} cell_row = [113] '%' [1x3 double] 'hello world' 6 Cell arrays and structures ENCMP 100 2011 by ECE, UofA Cell arrays: how to create (cont.) a column cell array >> cell_column = {113 ; '% ; [2, 3, 4] ; 'hello world'} cell_column = [ 113] '%' [1x3 double] 'hello world' 7 Cell arrays and structures ENCMP 100 2011 by ECE, UofA Cell arrays: how to create (cont.) a 2x2 cell array >> cell_matrix = {113 , '% ; [2, 3, 4] , 'hello world'} cell_matrix = [ 113] '%' [1x3 double] 'hello world' 8 Cell arrays and structures ENCMP 100 2011 by ECE, UofA Cell arrays: how to create (cont.) another method: create empty cell and assign values to specific elements, or start assigning values >> cell_example01 = cell(2,2) cell_example01 = >> cell_example02{2,2} = 12 cell_example03 = [12] 9 Cell arrays and structures ENCMP 100 2011 by ECE, UofA...
View Full Document

Page1 / 53

10_cell_main - Cell arrays, Structures, and Structure...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online