Cell Arrays UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.

Slides:



Advertisements
Similar presentations
Copyright © 2002 Pearson Education, Inc. Slide 1.
Advertisements

1 C++ Syntax and Semantics The Development Process.
Copyright © 2014 Dr. James D. Palmer; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Trees UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.1: Context-Free Grammars) David Martin With some.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Exam StatusExam Status Recap of Lab 7 ExampleRecap of Lab 7 Example.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
March R. Smith - University of St Thomas - Minnesota QMCS 130: Today’s Class Upcoming Exam – April 8Upcoming Exam – April 8 Structures ReviewStructures.
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.1: DFA’s) David Martin With some modifications.
Cells and Structures Array Cells and Array Structures.
Cells and Structures Array Cells and Array Structures.
MATLAB Cell Arrays Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University.
C ENTER FOR I NTEGRATED R ESEARCH C OMPUTING MATLAB
Foundations of (Theoretical) Computer Science Chapter 1 Lecture Notes (Section 1.2: NFA’s) David Martin With some modifications.
Solving ODEs UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Functions UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Numerical Integration UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Solving Linear Equations UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Debugging UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Time Complexity UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Regression UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Simulink SubSystems and Masking April 22, Copyright , Andy Packard. This work is licensed under the.
Recursion and Induction UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the.
Fall 2006AE6382 Design Computing1 Cell Arrays and Structures Learning Objectives Learn about characters, cell arrays & structures Topics Data Types Character.
Black Box Software Testing Copyright © 2003 Cem Kaner & James Bach 1 Black Box Software Testing Spring 2005 PART 7 -- FUNCTION TESTING by Cem Kaner, J.D.,
E177, Review of Matlab Spring, Copyright , Andy Packard. This work is licensed under the Creative Commons.
BEGINNING MULTIPLICATION BASIC FACTS Multiplication is REPEATED ADDITION. It is a shortcut to skip counting. The first number in the problem tells.
Sorting UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Script Files UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Objects and Classes UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Stability Region Analysis using composite Lyapunov functions and bilinear SOS programming Support from AFOSR FA , April 05-November 06 Authors.
Shared Mission, Sharing Resources: Librarians & Instructional Technologists Supporting Faculty Together This work is licensed under the Creative Commons.
Numerical Differentiation UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under.
IEEE Arithmetic UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Searching UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Struct Arrays UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
>> x = [ ]; y = 2*x y = Arrays x and y are one dimensional arrays called vectors. In MATLAB all variables are arrays. They allow functions.
Polynomials UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons.
Basics of Matlab UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Intro to Simulink April 15, Copyright , Andy Packard. This work is licensed under the Creative Commons.
Inheritance in Matlab Classes E177 February 14, Copyright , Andy Packard. This work is licensed.
Simulink Model Commands April 11, Copyright 2005, Andy Packard. This work is licensed under the Creative.
Java Software Solutions Lewis and Loftus Chapter 6 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Objects for Organizing Data.
Root Finding UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Get/Set Methods UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Intro to Simulink Modified by Gary Balas 20 Feb 2011 Copyright , Andy Packard. This work is licensed under.
Introduction to CMex E177 April 25, Copyright 2005, Andy Packard. This work is licensed under the Creative.
E177, Rules of Interruptibility of Callbacks March 4, Copyright , Andy Packard. This work is licensed.
Copyright Crash Course Laura Rivera EDTC
Chapter 4 Section 1 Organizing Data into Matrices.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Introduction to Java E177 April 29, me. berkeley
For/Switch/While/Try UC Berkeley Fall 2004, E77 me
ME190L Nyquist Stability Criterion UC Berkeley Fall
Reusable Graphics Objects UC Berkeley Fall 2004, E77 me
Class Info E177 January 22, me. berkeley
Regular Expressions: Searching strings for patterns April 24, 2008 Copyright , Andy Packard and Trent Russi. This work is licensed under the Creative.
E177, Graphics Objects in Matlab February 26, me
Black Box Software Testing Fall 2005 Overview – Part 1 of 3
Class Intro/TDD Intro 8/23/2005
E177, Reference/Assignment for Classes: Intro February 12, Copyright , Andy Packard. This work.
Function Handles UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Arrays in Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Variables and Constants
Basics of Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

Cell Arrays UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative Commons Attribution-ShareAlike License. To view a copy of this license, visit or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Cell Arrays (chapter 7, page ) Numeric arrays (class name is double) are rectangular arrays of numbers. Character arrays (class name is char) are rectangular arrays of characters. Cell arrays (class name is cell) are rectangular arrays of containers, whose contents may be –double arrays –character arrays, or even –cell arrays

Review of Cell Arrays: Creating Use curly brackets { and } to wrap a variable 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 = { }; >> scores = { [ ] };

Concatenating Stack all three containers next to one another, creating a 1-by- 3 array of containers. >> ClassInfo = [ name SID scores ]; ClassInfo is a 1-by-3 array of containers. It is called a cell array. >> size(ClassInfo) >> class(ClassInfo) >> whos Container 1 Contents of Container 1

class and size for cell arrays ClassInfo is a 1-by-3 array of containers--a cell array. >> size(ClassInfo) >> class(ClassInfo) >> whos Using parenthesis () to access parts of the array keeps the containers (remember, it is an array of containers). >> ClassInfo(1) >> tmp = ’Andy Packard’ >> isequal(ClassInfo(1),’Andy Packard’) >> size(ClassInfo(1)) >> class(ClassInfo(1))

Referencing contents of cells Use curly brackets to access the contents of a container. >> ClassInfo{1} >> ClassInfo{2} >> ClassInfo{3} >> isequal(ClassInfo{2}, ) >> isequal(ClassInfo{1},tmp)

3-by-2 Cell Array example Create a 3-by-2 array of containers >> A = [ {[1 2;3 4]} {’andy’} ;... {pi} {rand(20,2)};... {[’E77’;’fun’]} {zeros(1,6)} ];

>> A = [ {[1 2;3 4]} {’andy’} ;... {pi} {rand(20,2)};... {[’E77’;’fun’]} {zeros(1,6)} ]; View it as 3-by-2 array of containers 2-by-2 double array in container 1,1 1-by-4 char array in container 1,2

Quiz: References into a 3-by-2 Cell Array >> size(A) >> class(A) >> B = A(1,1); >> size(B), class(B) >> C = A{1,1} >> size(C), class(C) >> A{1,1}(2,2) >> D = A(:,2) >> size(D), class(D) >> D{3}(3) >> [’s’ D{1} ’ beach’] Recall what A is

CELL creates Cell Arrays with empty contents Create a 3-by-4 array of containers. By default, the contents of each container will be an empty array (0-by-0) double array. >> E = cell(3,4) Put the array [7 8 9] in the contents of the 1,1 container >> E{1,1} = [ ]; Try to insert the array [ ] as the 1,2 container >> E(1,2) = [ ]; Insert a container (whose contents is the array [ ] ) in the 1,2 element of E (recall, all elements of E are containers) >> E(1,2) = { [ ] }; What is different in >> E{1,3} = { [ ] };

Commands to look at on your own num2cell cell2mat mat2cell cellstr celldisp iscell