1 / 12

EGR115

EGR115. Part1 – weeks 1 through 7. Part2 – Storing data. Arrays Files. Variables double / int char Equations MATLAB can skip if & switch MATLAB can repeat while & for. Part3 – Organizing lines of code. functions. Arrays – the Basics. Arrays Scalar Vectors Matrices.

ember
Télécharger la présentation

EGR115

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. EGR115 Part1 – weeks 1 through 7 Part2 – Storing data Arrays Files • Variables • double / int • char • Equations • MATLAB can skip if & switch • MATLAB can repeat while & for Part3 – Organizing lines of code • functions

  2. Arrays – the Basics Arrays Scalar Vectors Matrices

  3. 1. An array • An array is a collection of data into one variable • The array has a more precise name, depending on the dimensions of the variable: • A “scalar” • A “vector” • A “matrix” • When talking about the dimension of any array, you will hear: “This array is a ___ by ____.” For example: • This array is a 3 by 4. 3 is the number of rows, 4 is the number of columns. The difference…

  4. 1st . “A scalar” • A single value. • This array is a 1 by 1. • Example: the number 7 is a scalar. age = 17; %creates a scalar variable weight = 145.32; %another scalar variable

  5. 2nd . “Vector” – math In 2D:

  6. 2nd . “Vector” – math In 2D: In 3D: The vector OP has initial point at the origin O(0,0,0) and terminal point at P(2,3,5). We can draw the vector OP as follows: Source: http://www.intmath.com/Vectors/1_Vector-concepts.php In 3D:

  7. More than just math “Vector” – MATLAB • A vector is a one-dimensional collection of data • “all the temperatures readings during take-off” • “all the pressures recorded during Hurricane Katrina” • “an (x,y,z) coordinate” • A vector can only be of two types: a column, or a row • For an array to be a vector, only ONE of this variable's dimension is 1. A column vector (“m by 1”) A row vector (“1 by m”)

  8. Vectors, end. • Vectors are usually thought of as “row vectors” or “column vectors”, but there exists one more: The “empty vector” – a variable in MATLAB that contains no values. To make an empty vector, use the empty brackets: array = []; • Why do this? • Create a variable, much like a container ready to accept values. • Erase the previous content of an array, without destroying the variable itself.

  9. 3rd . A “matrix” • Both dimensions are greater than 1. • Can be used to: • Represent mathematical matrices, or • Store related information • First row: temperature of different points in a nozzle • Second row: pressure at those same points • Third row: density at those same points an “r by c”

  10. 3rd . A “matrix”, vocabulary • LEARN this NOW – everything depends on you referring to these correctly! 1 2 3 4 5 6 7 8 9 0 3 1 5 6 1 4 3 5 6 7 3 1 2 0 0 ROW!

  11. 3rd . A “matrix”, vocabulary • LEARN this NOW – everything depends on you referring to these correctly! 1 2 3 4 5 6 7 8 9 0 3 1 5 6 1 4 3 5 6 7 3 1 2 0 0 COLUMN!

  12. At this point in time… • Arrayscan only have 1 data-typeand 1 value per box. NUMERICAL CHAR MIX  MULTIPLE VALUES per box 

More Related