These two examples illustrate the difference between array multiplication s. In this definition the productis the sum of the individual element products that is.If we had wanted to find.only tile total miles traveled, we could have used another definition of multiplication, denoted by s*t I This vector contains the miles traveled by the aircraft on each leg of the trip. The corresponding element in t and that the resulting products are used to form a row vector having the same number of elements as s and t. * sigmfies that each element in s is multiplied by * t to produce the row vector whose elements are the products of the corresponding elements in s and t: To find the miles traveled on each leg, we multiply the speed by the time. The table gives the speed of an aircraft on each leg of a certain trip and the time spent on each leg. We can define a row vector’ s containing the speeds and: a row vector t containing the times for each leg. The data in Table 2.3-2 illustrates the difference between the two types of multiplication that are defined in ~TLAB. Table 2.3-1 Element-by-element operations In this case the scalar is added or subtracted from each element in the array. The only exception to this rule in MATLAB occurs when we add or subtract a scalar to or from an array. For addition these properties mean thatĪ + B + C = B + C + A = A + c + B (2.3-3)Īrray addition and subtraction require that both arrays have the same size. ‘.”l: The addition shown in equation 2.3-1 is performed in MATLAB asfollows:Īrray addition and subtraction are associative and commutative. For example:Īrray subtraction is performed in a, similar way. Thus C = A + B implies that cij = aij + bij if the arrays are matrices. Figure 2.3-2b illustrates vector addition in three dimensions. When two arrays have identical size, their sum or difference has the same size and is obtained by adding or subtracting their corresponding elements. To add the vectors r = [ 3, 5, 2) and v = [ 2, – 3, 1) to create w in MATLAB, you type w = r + v. (b) Addition of vectors in three dimensions.Ĭomponents. Vector addition can be done either graphically (by using the parallelogram law in two dimensions (see Figure 2.3-2a), or analytically by adding the correspondingįigure 2.3-2 ‘yector addition. Each form has its own applications, which we illustrate by examples. In this section we introduce one form, called array operations, which are also called element-by-element operations. In the next section we introduce matrix-operations. MATLAB has two forms of arithmetic operations on arrays. Division and exponentiation must also be carefully defined when you are dealing with operations between two arrays. In fact. MATLAB uses two definitions of multiplication: (l) array multiplication and However, multiplication of two arrays is not so straightforward. Thus multiplication of an array by a scalar is easily defined and easily carried out. See Figure 2.3-1 for the geometric interpretation of scalar multiplication of a vector in three dimensional space. Multiplying a matrix A by a scalar w produces a matrix whose elements are the elements of A multiplied hf w.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |