CMPS 1371 Introduction to Computing for Engineers STRUCTURE ARRAYS.

Slides:



Advertisements
Similar presentations
E LEMENTARY D ATA STRUCTURES. A RRAYS Sequence of elements of similar type. Elements are selected by integer subscripts. For example, signs: array[37:239]
Advertisements

Pointers.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Chapter 8. Data Structure: A variable that stores more than one value Matrices/vectors and character arrays are types of data structures MATLAB also provides.
COMP 116: Introduction to Scientific Programming Lecture 37: Final Review.
Structures. An array allows us to store a collection of variables However, the variables must be of the same type to be stored in an array E.g. if we.
Chapter 10 Introduction to Arrays
© 2004 Goodrich, Tamassia Hash Tables1  
1 A Balanced Introduction to Computer Science, 2/E David Reed, Creighton University ©2008 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. ETC - 1 What comes next? Recursion (Chapter 15) Recursive Data Structures.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
Chapter 7 Introduction to Arrays Part I Dr. Ali Can Takinacı İstanbul Technical University Faculty of Naval Architecture and Ocean Engineering İstanbul.
Cells and Structures Array Cells and Array Structures.
General Computer Science for Engineers CISC 106 Lecture 23 Dr. John Cavazos Computer and Information Sciences 4/15/2009.
Cells and Structures Array Cells and Array Structures.
Concatenation MATLAB lets you construct a new vector by concatenating other vectors: – A = [B C D... X Y Z] where the individual items in the brackets.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Chapter 11: Structured Data. Slide Introduction An array makes it possible to access a list or table of data of the same data type by using a single.
Java Unit 9: Arrays Declaring and Processing Arrays.
Computer Science 121 Scientific Computing Winter 2014 Chapter 4 Collections and Indexing.
COMP 116: Introduction to Scientific Programming Lecture 25: Cell Arrays and Structures.
Introduction to MATLAB Session 1 Prepared By: Dina El Kholy Ahmed Dalal Statistics Course – Biomedical Department -year 3.
Structs. Structures We already know that arrays are many variables of the same type grouped together under the same name. Structures are like arrays except.
1 Lesson 22 Getting Started with Access Essentials Computer Literacy BASICS: A Comprehensive Guide to IC 3, 3 rd Edition Morrison / Wells.
The Document Object Model. Goals Understand how a JavaScript can communicate with the web page in which it “lives.” Understand how to use dot notation.
 A database is a collection of data that is organized so that its contents can easily be accessed, managed, and updated. What is Database?
Lesson 17 Getting Started with Access Essentials
Fall 2006AE6382 Design Computing1 Cell Arrays and Structures Learning Objectives Learn about characters, cell arrays & structures Topics Data Types Character.
Problem Solving for Programming Session 8 Static Data Structures.
Chapter 17 Creating a Database.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 11 Structured Data.
 Introduction to Computer Science COMP 51 – Fall 2012 – Section 2 Structures.
1 Chapter 11 Structured Data. 2 Topics 10.1 Abstract Data Types 10.2 Combining Data into Structures 10.3 Accessing Structure Members 10.4 Initializing.
Copyright © 2012 Pearson Education, Inc. Chapter 11: Structured Data.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11: Structured Data.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
 2007 Pearson Education, Inc. All rights reserved C Structures, Unions, Bit Manipulations and Enumerations.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11: Structured Data.
Working with Arrays in MATLAB
A Balanced Introduction to Computer Science, 3/E David Reed, Creighton University ©2011 Pearson Prentice Hall ISBN Chapter 17 JavaScript.
Copyright © 2012 Pearson Education, Inc. Chapter 11: Structured Data.
Struct Arrays UC Berkeley Fall 2004, E77 Copyright 2005, Andy Packard. This work is licensed under the Creative.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Covenant College December 18, Laura Broussard, Ph.D. Visiting Professor COS 131: Computing for Engineers Chapter 7: Cell Arrays and Structures.
Array Creation ENGR 1181 MATLAB 2. Civil engineers store seismic data in arrays to analyze plate tectonics as well as fault patterns. These sets of data.
Lecture 5 functions 1 © by Pearson Education, Inc. All Rights Reserved.
CMPS 1371 Introduction to Computing for Engineers CHARACTER STRINGS.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
CNG 140 C Programming (Lecture set 12) Spring Chapter 13 Dynamic Data Structures.
Array Accessing and Strings ENGR 1187 MATLAB 3. Today's Topics  Array Addressing (indexing)  Vector Addressing (indexing)  Matrix Addressing (indexing)
Introduction to Computers and Programming Class 24 Structures (structs) Professor Avi Rosenfeld.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 11: Structured Data.
Chapter 5 Murach's JavaScript and jQuery, C1© 2012, Mike Murach & Associates, Inc.Slide 1.
Chapter Structured Data 11. Combining Data into Structures 11.2.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
7.5 Using Stored-Procedure and Triggers NAME MATRIC NUM GROUP Muhammad Azwan Bin Khairul Anwar CS2305A Muhammad Faiz Bin Badrol Shah CS2305B.
CSC 212 – Data Structures Lecture 28: More Hash and Dictionaries.
Winter 2009 Tutorial #6 Arrays Part 2, Structures, Debugger
11 Chapter Structured Data
Practical Office 2007 Chapter 10
Chapter 11: Structured Data.
Chapter 10 Sparse, Cell, & Structure Arrays
Week 9 – Lesson 1 Arrays – Character Strings
Chapter 8 Data Structures: Cell Arrays and Structures
Fondamenti di informatica structures
Array Creation ENGR 1181 MATLAB 02.
Chapter 8 Data Structures: Cell Arrays and Structures, Sorting
Working with Arrays in MATLAB
Presentation transcript:

CMPS 1371 Introduction to Computing for Engineers STRUCTURE ARRAYS

Structure Arrays Similar to Cell Arrays Multiple arrays of differing data types can be stored in structure arrays Instead of using content indexing each of the matrices is given a location called a field

Structures This class of arrays allows you to store dissimilar arrays together. The elements in the structure are accessed using named fields You create a structure array either by using assignment statements or by using the struct function. Structure arrays use the dot notation (.) to specify and to access the fields.

Structures Think about a student database (e.g. name, social security number, address, test scores). There are four fields (4 field names): 3 string and 1 vector containing numerical elements. A structure consists of all this information for a single student and a structure array is an array of such structures for different students. name ssn test scores Student record

Arrangement of data in the structure array student.

Entering Data We can enter the data directly >> student.name = 'John Smith'; >> student.ssn = ' '; >> student. = >> student.tests = [67,75,84];

Entering Data We can also enter the data through a structure function “struct”: >> student = struct(‘name’, ‘John Smith’, ‘ssn’, ‘ ’, ‘ ’, ‘tests’, [67,75,84])

Access Data The name student is now used to refer to the entire array of structures. We can access elements of a structure array as if it was a normal array For example: >> student(1)

Functions The Matlab function fieldnames recovers all the field names associated with a structure. returns a cell array of strings. For example: >> fieldnames(student) ans = 'name' 'ssn' ' ' 'tests‘ Matlab function rmfield - removes fields from a structure.

Arrays of structures Often we will want multiple instances of a single structure. We can build up an array of structures. We call this array a structure array. Matlab allows a structure array to grow automatically.

Add another student >>student(2).name = ‘Mary Jones’; Since we only specified the name field of student(2), Matlab initializes the remaining fields to empty arrays: We can then fill in extra details as required. >>student(2).ssn = ‘ ’; >>student(2). = >>student(2).tests = [84, 78, 93];

Why are structures so much better Structures use the "name" of a "field" to access the data…so the name can be useful things like 'artist'. Compared to "3 rd element" Structures can be thought of as a "data structure" –organizes the data in a logical way that can be applied many times. Structures can be put into arrays as long as the structures all have the same fields. This makes having many "objects" of the same type easy.