Programming Environment S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: Cells and Structures.

Slides:



Advertisements
Similar presentations
R for Macroecology Aarhus University, Spring 2011.
Advertisements

Matlab Intro Simple introduction to some basic Matlab syntax. Declaration of a variable [ ] Matrices or vectors Some special (useful) syntax. Control statements.
Multidimensional Array
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.
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
Solving Algebraic Equations
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
JavaScript Part 6. Calling JavaScript functions on an event JavaScript doesn’t have a main function like other programming languages but we can imitate.
Numerical Operations S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: Numerical Integration.
Programming Environment S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: Control Flow.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Matlab Basics Introduction to Matlab: Matrix Operations.
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.
Baburao Kamble (Ph.D) University of Nebraska-Lincoln Data Analysis Using R Week2: Data Structure, Types and Manipulation in R.
Numerical Operations S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: Polynomial Manipulations.
COMP 116: Introduction to Scientific Programming Lecture 25: Cell Arrays and Structures.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Yuval Hart, Weizmann 2010© 1 Introduction to Matlab & Data Analysis Tutorial 13: That’s all, Folks! Please change directory to directory E:\Matlab (cd.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
Fall 2006AE6382 Design Computing1 OOP: Creating a Class More OOP concepts An example that creates a ASSET class and shows how it might be used Extend the.
GUI Input and Output Greg Reese, Ph.D Research Computing Support Group Academic Technology Services Miami University.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: User Input / Output Programming Environment.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Working with GridView Control: Adding Columns. Adding Buttons to a Bound GridView: 1. Drag the WebProduct table from Data connection to a page 2. Demo.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
MAE 1202: AEROSPACE PRACTICUM An Introduction to MATLAB: Part 2 Mechanical and Aerospace Engineering Department Florida Institute of Technology Developed.
Lecture 2 - Matlab Introduction CVEN 302 June 5, 2002.
Digital Image Processing Lecture4: Fundamentals. Digital Image Representation An image can be defined as a two- dimensional function, f(x,y), where x.
Scope When we create variables and functions, they are limited in where they are visible and where they can be referenced For the most part, the identifiers.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Working with Arrays in MATLAB
Database Objective Demonstrate basic database concepts and functions.
Matlab Basic. MATLAB Product Family 2 3 Entering & Quitting MATLAB To enter MATLAB double click on the MATLAB icon. To Leave MATLAB Simply type quit.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
Digital Image Processing Introduction to MATLAB. Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The.
Introduction to Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
1 Lecture 4 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
CSCI 130 More on Arrays. Multi-dimensional Arrays Multi - Dimensional arrays: –have more than one subscript –can be directly initialized –can be initialized.
Array Accessing and Strings ENGR 1187 MATLAB 3. Today's Topics  Array Addressing (indexing)  Vector Addressing (indexing)  Matrix Addressing (indexing)
Arrays. Topics to be Covered... Arrays ◦ Declaration ◦ Assigning values ◦ Array manipulation using loops Multi-dimensional arrays ◦ 2D arrays ◦ Declaration.
SCRIPTS AND FUNCTIONS DAVID COOPER SUMMER Extensions MATLAB has two main extension types.m for functions and scripts and.mat for variable save files.
Cell Arrays: An Introduction Without an understanding of how cell arrays work and how to interact with them, cell arrays can be one of the most frustrating.
Multidimensional Arrays tMyn1 Multidimensional Arrays It is possible to declare arrays that require two or more separate index values to access an element.
Data Structures: Multi-Dimensional Arrays Damian Gordon.
MULTI-DIMENSIONAL ARRAYS 1. Multi-dimensional Arrays The types of arrays discussed so far are all linear arrays. That is, they all dealt with a single.
Introduction to CMex E177 April 25, Copyright 2005, Andy Packard. This work is licensed under the Creative.
13/10/2016CS150 Introduction to Computer Science 1 Multidimensional Arrays  Arrays can have more than one column  Two dimensional arrays have two columns.
Sundermeyer MAR 999 Spring Laboratory in Oceanography: Data and Methods MAR599, Spring 2009 Miles A. Sundermeyer Data Handling in Matlab.
An Introduction to Programming in Matlab Emily Blumenthal
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
How to use MATLAB (using M-files) Double click this icon To start Matlab 6.5.
Other Kinds of Arrays Chapter 11
Cell Arrays Definition Creating Cell Arrays Referencing Cell Arrays
Outline Matlab tutorial How to start and exit Matlab Matlab basics.
Advanced Data Import & Export Jeff Henrikson
Digital Image Processing using MATLAB
MATLAB How to use (using M-files) Double click this icon
MATLAB How to use (using M-files) Double click this icon
CSCI N207 Data Analysis Using Spreadsheet
Multidimensional array
Matlab Basic Dr. Imtiaz Hussain
Fundamentals of Image Processing Digital Image Representation
Introduction to Matlab:
Introduction to Matlab: Element by Element Operations
Presentation transcript:

Programming Environment S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: Cells and Structures

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 2 Cell and Structure Topics n Cell Arrays Cell Arrays n Preallocating Cells Preallocating Cells n Structures Structures n Structure Example: dir Structure Example: dir

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 3 Cell Arrays n Cells are containers that hold other Matlab Arrays n One Cell Array may contain u A Real Matrix u An Array of Strings u Vector of complex values u A Cell of other Matlab Arrays n Cells may be High-Dimensional (more than just 2D)

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 4 Cell Array Example n 2 Row by 3 Column Array of Elements

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 5 Creating a Cell Array n Cell Indexing » MyCell(1,1) = {[1 2 3; 2 3 4]}; » MyCell(1,2) = {1:0.2:2}; » MyCell(2,1) = {4+7i}; » MyCell(2,2) = {['The '; 'LAST';'cell']}; n Content Indexing » MyCell{1,1} = [1 2 3; 2 3 4]; » MyCell{1,2} = 1:0.2:2; » MyCell{2,1} = 4+7i; » MyCell{2,2} = ['The '; 'LAST';'cell'];

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 6 » MyCell ={ [1 2 3; 2 3 4], 1:0.2:2; 4+7i, ['The '; 'LAST';'cell']} Cell = [2x3 double] [1x6 double] [ i] [3x4 char ] » MyCell(1,1) ans = [2x3 double] » MyCell{1,2} ans = Cell Example To View Type or 1D Contents To View Contents

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 7 » B=cell(3,2) B = [] [] » B(2,1)={1:0.01:2} B = [] [] [1x101 double] [] [] [] Preallocating Cells To preallocate a Cell Array, use cell command Assigning a cell displays properties of entire cell

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 8 Structures n Structures are Matlab arrays with names “Data Containers” called fields n A structure may hold any type of Matlab data n Structure Arrays are multidimensional arrays of structures (1D, 2D, 3D, …) n A single structure is a 1x1 Structure Array

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 9 » turtle.name = 'Ted'; » turtle.type = 'aquatic'; » turtle.age = 10; » turtle.color = {'Brown Shell','Red Lines'} turtle = name: 'Ted' type: 'aquatic’ age: 10 color: {1x2 cell} Building Structures n Matlab Structures do not require definition like C structures do n Simply type the structure name and assigned field Stored in Order of Assignment

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 10 Adding Structures to Array » turtle(2).name ='OneShot'; » turtle(2).type ='land'; » turtle(2).age = 1; » turtle(2).color ={'Sandy brown'} Not same size as ' aquatic ' Displays size and field names Any Cell turtle = 1x2 struct array with fields: name type age color

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 11 Dir Command Example » D=dir('*.m') Find All files with.m extension D = name: 'comparescores.m’ Only one is found so date: '15-Jul :43:42’ all fields are shown bytes: 4677 isdir: 0 » D2=dir('*.txt') Find All files with.txt extension D2 = 4x1 struct array with fields: Many files are found name so only field names date are shown bytes isdir

MATLAB Programming: U of M-Dearborn ECE Department Introduction to MATLAB and its Toolboxes Cells and Structures 12 Accessing Structure Data D=dir('*.TXT');% List of all text Files FileNames = Result of Code u1_040898_1601.txt u1_040898_1602.txt u1_041398_1428.txt u1_041398_1429.txt maxFiles = size(D,1);% Number of retrieved text files for I=1:maxFiles,% For all files in the directory FileNames(I,1:size(D(I).name,2))= D(I).name; end FileNames is created and updated as Necessary