Chapter 2_Array.ppt

# Chapter 2_Array.ppt - Arrays Arrays Arrays Two-dimensional...

This preview shows pages 1–23. Sign up to view the full content.

Arrays

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Arrays Arrays Two-dimensional Arrays Element-by-element Operations Matrix Operations Polynomial Operations Using Arrays
The array is the fundamental form of Matlab, uses to store data. Scalars: one row and one column (special case) Vectors: Row : one row and multiple columns Column: multiple rows and one column Matrices: multiple rows and multiple columns

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
In Matlab, a vector, or any list of numbers, can be entered in a horizontal (row) or vertical (column) vectors. Ex: the data from the previous slide can be entered in rows:[1984 1986 1988 1990 1992 1994 1996] [127 130 136 145 158 178 211] or in column: 211 178 158 145 136 130 127 1996 1994 1992 1990 1988 1986 1984

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
A vector is created by typing the elements (numbers) Inside square brackets [ ]. To create a ROW VECTOR, type a space or a comma between the elements inside the square brackets.
NOTE: Matlab is not “picky” about how the data is typed in. You can type spaces before and/or after the sign “=“. Between the elements you can have a space in addition to the comma, or you can type more than one space.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
To create a COLUMN VECTOR, type a left bracket [, and Then enter the elements with a semicolon between them, or press <ENTER> after each element. Type a right bracket ] after the last element.
CREATING VECTORS WITH CONSTANT SPACING Two common methods: - Specify first term : step size : last term - linspace (first term, last term, number of terms)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern