{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture_05_CellStruct

# Lecture_05_CellStruct - Final Exam Info Exam Group 12...

This preview shows pages 1–8. Sign up to view the full content.

Final Exam Info Exam Group 12: Monday, December 17, 5-8PM Alternate time for final exam conflict (you have a MWF 1-2 course, with exam group 12) Thursday, December 20, 4-7PM Alternate time for exceedingly exceptional exceptions (contact us ASAP) Monday, December 10, 5-8PM

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

View Full Document
E7 Cell and Struct Arrays Fall, 2007 September 12, 2007 Copyright 2004-7, Andy Packard & Roberto Horowitz. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
Cell Arrays So far, we know about 3 classes Numeric arrays (class name is double ) are rectangular arrays of real/complex numbers (double → double precision, ~16 digits in base 10) Character arrays ( char ) are rectangular arrays of characters. Logical arrays ( logical ) rectangular arrays of logicals (value is 0 or 1) An object is a specific instance, [2 3.4 5;1 -10 0] is an object of class double ’NameRank’ is an object of class char Cell arrays (class name is cell ) are rectangular arrays of containers . The contents of a container may be a double array (ie., an object of class double ) char array logical array, or even cell array, or… object of any other Matlab class

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

View Full Document
The CLASS command If A is an Matlab object, then class(A) is character string (ie., char ), whose value is the class of A (eg., double, char, cell, struct, uint32, etc) . The command class is also used to create user-defined classes (covered in E177). Examples class(rand(5,6)) class(’this is a string 1234.56’) class(5==6) class(class(rand(5,6)))
The SIZE command If A is an array, then size(A) is a 1-by-2 array. The (1,1) entry is the number of rows of A The (1,2) entry is the number of columns of A If A is an array, then size(A,1) is the number of rows of A size(A,2) is the number of columns of A Examples >> A = rand(5,6); >> szA = size(A) >> size(A,1) >> size(A,2) If A is a 3-d array, then size(A) is 1-by-3, etc. These high dimension arrays are covered extensively in E177

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

View Full Document
Cell Arrays: Creating Think: “array of containers; contents of which are Matlab objects” Use curly brackets { and } to “ put an object in a container ”. Example: Create a 1-by-1 container, whose contents is the 1- by-12 character array ‘Andy Packard’ >> name = { ’Andy Packard’ }; >> size(name) >> class(name) Create two more 1-by-1 containers with different contents >> SID = { 12345678 }; >> scores = { [82 71 64 88 99] };
Review of Double/Char/Logical Arrays: Concatenation Recall: square brackets are used for concatenation (stacking) [ Object1 , Object2 ; Object3 ; Object4 ] This works for all types of objects, including cell arrays. Only restriction is that row/column dimensions must make sense.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 28

Lecture_05_CellStruct - Final Exam Info Exam Group 12...

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

View Full Document
Ask a homework question - tutors are online