E77: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

E77: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS

Description:

Scalar and element-wise addition, multiplication, etc. ... Display of cell contents (celldisp, cellplot) Generation of empty cell arrays (cell) ... – PowerPoint PPT presentation

Number of Views:24
Avg rating:3.0/5.0
Slides: 9
Provided by: pack3
Category:

less

Transcript and Presenter's Notes

Title: E77: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND ENGINEERS


1
E77 INTRODUCTION TO COMPUTER PROGRAMMING FOR
SCIENTISTS AND ENGINEERS
  • Lecture Outline
  • 1. Two-dimensional arrays revisited
  • 2. String arrays
  • 3. Cell arrays

2
Two-dimensional arrays revisited
  • 1. Two-dimensional arrays revisited
  • Two-dimensional simple arrays consist of m rows
    and n
  • columns of real numbers. For example
  • The two-dimensional array A consists of m 2
    rows and
  • n 3 columns.
  • All rows (respectively, columns) in a simple
    array contain
  • the same number of elements.

3
Two-dimensional arrays revisited
  • Important operations on two-dimensional arrays
    include
  • Input and output
  • Indexing and sizing
  • Scalar and element-wise addition, multiplication,
    etc.
  • Addition, deletion and redefinition of rows or
    columns
  • Reshaping
  • Contents analysis (sort, sum, find
    maximum/minimum)

4
Two-dimensional arrays revisited
  • Example
  • Weigh homework, midterm and final exam grades
  • appropriately to obtain the final numerical mark
    for a group
  • of students registered in a course.
  • Weights homework 35, midterms 40, final 25

5
String arrays
  • 2. String arrays
  • Two-dimensional string arrays are simple
    two-dimensional
  • arrays of character strings. For example
  • What is the dimension of the Football_score
    array?
  • The symbols 14 and 41 are input as strings, not
    numbers.
  • String arrays are of limited use. Why?

6
Cell arrays
  • 3. Cell arrays
  • A cell array is a data type which permits the
    grouping of
  • dissimilar elements (themselves arrays) into a
    single variable.
  • Cell arrays are a very powerful tool for data
    management.

A cell
A string
7
Cell arrays
  • Main operations involving cell arrays
  • Input and indexing (parentheses vs. curly
    brackets)
  • ( ) to identify a cell (but not its contents)
  • to define the contents of a cell
  • Display of cell contents (celldisp, cellplot)
  • Generation of empty cell arrays (cell)
  • Concatenation and extraction of sub-arrays of a
    cell
  • array

8
Summary
  • What did we learn today?
  • Two-dimensional simple arrays are easy to
    manipulate
  • in MATLAB and can be used to store arithmetic
    and
  • string information.
  • String arrays are not very flexible.
  • It is possible to store arithmetic and string
    data of
  • differing sizes in cell arrays.
  • In cell arrays, one needs to distinguish between
    cell
  • indexing (which cell?) and content indexing
    (what is
  • the content of a cell?).
Write a Comment
User Comments (0)
About PowerShow.com