02.03.2016 Views

MATLAB by rudra pratap

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.2 Lesson 2: Creating and Working with Arrays of Numbers<br />

21<br />

2.2 Lesson 2: Creating and Working with Arrays<br />

of Numbers<br />

Goa/: To learn how to create arrays and vectors and how to perform arithmetic<br />

and trigonometric operations on them.<br />

An array is a list of numbers or expressions arranged in horizontal rows and vertical<br />

columns. When an array has only one row or column, it is called a vector. An array<br />

with m rows and n columns is called a rrw.trix of size m x n.<br />

information.<br />

What you are going to learn<br />

See Sp,etion 3.1 for more<br />

Time Estimates<br />

Lesson: 15 minutes<br />

Exercises: 45 minutes<br />

• How to create row and column vectors.<br />

• How to create a vector of n numbers linearly (equally) spaced between two<br />

given numbers a and b.<br />

• How to do simple arithmetic operations on vectors.<br />

• How to do array operations:<br />

·*<br />

./<br />

term-<strong>by</strong>-term multiplication,<br />

term-<strong>by</strong>-term division, and<br />

term-<strong>by</strong>-term exponentiation.<br />

• How to use trigonometric functions with array arguments.<br />

• How to use elementary math functions such as square root, exponentials, and<br />

logarithms with array arguments.<br />

This lesson deals primarily with 1-D arrays, i.e., vectors. One of the exercises<br />

introduces you to 2-D arrays, i.e., matrices. There are many mathematical concepts<br />

associated with vectors and matrices that we do not mention here. If you have some<br />

background in linear algebra, you will find that <strong>MATLAB</strong> is set up to do almost<br />

any matrix computation (e.g., inverse, determinant, rank).<br />

Method: You already know huw to launch <strong>MATLAB</strong>. Co ahead and try the<br />

commands shown in Fig. 2.2. Once again, you are going to reproduce the results<br />

shown.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!