Engr/Math/Physics 25 Chp2 MATLAB Arrays: Part-1 Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 1 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Learning Goals Learn to Construct 1-Dimensional Row and Column Vectors Create MULTI-Dimensional ARRAYS and MATRICES Perform Arithmetic Operations on Vectors and Arrays/Matrices Analyze Polynomial Functions Engineering/Math/Physics 25: Computational Methods 2 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Position Vector The vector p can be specified by three components: x, y, and z, and can be written as: p xi yj zk or p x, y , z • Where i, j, k are UNIT-Vectors Which are || To The CoOrd Axes MATLAB can accommodate Vectors having more than 3 Elements • See MATH6 for more info on “n-Space” Engineering/Math/Physics 25: Computational Methods 3 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt ROW & COLUMN Vectors To create a ROW vector, separate the elements by COMMAS >>p = [3,7,9] p = 3 7 9 p 3, 7, 9 The TRANSPOSE Operation Swaps Rows↔Columns Engineering/Math/Physics 25: Computational Methods 4 Use the Transpose operator (‘) to make a COLUMN Vector >>p = [3,7,9]' p = p 7 3 9 7 9 >>g = [3;7;9] Create Col-Vector g = 3 Directly with 7 SEMICOLONS 9 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt 3 “Appending” Vectors Can create a NEW vector by ''appending'' one vector to another e.g.; to create the row vector u whose first three columns contain the values of r = [2,4,20] and whose 4th, 5th, & 6th columns contain the values of w = [9,-6,3] • Typing u = [r,w] yields vector u = [2,4,20,9,-6,3] >> r = [2,4,20]; w = [9,-6,3]; >> u = [r,w] u = 2 4 20 9 -6 Engineering/Math/Physics 25: Computational Methods 5 3 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Colon (:) Operator The colon operator (:) easily generates a large vector of regularly spaced elements. Typing >>x = [m:q:n] • creates a vector x of values with a spacing q. The first value is m. The last value is n IF m - n is an integer multiple of q. IF NOT, the last value is LESS than n. >> p = [0:2:8] p = 0 2 4 6 8 >> r = [0:2:7] r = 0 2 4 6 Engineering/Math/Physics 25: Computational Methods 6 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Colon (:) Operator cont. To create a row vector z consisting of the values from 5 to 8 in steps of 0.1, type z = [5:0.1:8]. If the increment q is OMITTED, it is taken as the DEFAULT Value of +1. >> s =[-11:-6] s = -11 -10 -9 >> t = [-11:1:-6] t = -11 -10 -9 Engineering/Math/Physics 25: Computational Methods 7 -8 -7 -6 -8 -7 -6 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt linspace Comand The linspace command also creates a linearly spaced row vector, but instead you specify the number of values rather than the increment The syntax is linspace(x1,x2,n), where x1 and x2 are the lower and upper limits and n is the number of points • If n is omitted, then it Defaults to 100 Thus EQUIVALENT statements >> linspace(5,8,31) Engineering/Math/Physics 25: Computational Methods 8 = >>[5:0.1:8] Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt logspace Comand The logspace command creates an array of logarithmically spaced elements Its syntax is logspace(a,b,n), where n is the number of points between 10a and 10b For example, x = logspace(-1,1,4) produces the vector x = [0.1000, 1 1 0.4642, 2.1544, 10.000] x 10 1 ,10 3 ,10 3 ,101 >> x = logspace(-1,1,4); >> y = log10(x) y = -1.0000 -0.3333 a 0 b a n 1 a 1 b a n 1 x 10 ,10 ,10 0.3333 a 2 b a n 1 1.0000 a n 1 b a n 1 , ,10 If n is omitted, the no. of pts defaults to 50 Engineering/Math/Physics 25: Computational Methods 9 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt logspace Example Consider this command >> y =logspace(-1,2,6) y = 0.1000 0.3981 1.5849 Calculate the Power of 10 increment p b a n 1 In this case p 2 1 6 1 3 5 0 .6 Engineering/Math/Physics 25: Computational Methods 10 6.3096 25.1189 100.0000 for k = 1→6, then the kth y-value y k 10 a p k 1 In this Case k Power yk 1 -1 0.1000 2 -0.4 0.3981 3 0.2 1.5849 4 0.8 6.3096 5 1.4 25.1189 6 2 100.0000 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt logspace Example (alternative) Consider this command >> y =logspace(-1,2,6) y = 0.1000 0.3981 1.5849 6.3096 25.1189 100.0000 1.4000 2.0000 Take base-10 log of the above >> yLog10 = log10(y) yLog10 = -1.0000 -0.4000 0.2000 0.8000 Calc Spacing Between Adjacent Elements with diff command >> yspc = diff(yLog10) yspc = 0.6000 0.6000 0.6000 0.6000 0.6000 p b a n 1 2 1 6 1 3 5 Engineering/Math/Physics 25: Computational Methods 11 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vector: Magnitude, Length, and Absolute Value Keep in mind the precise meaning of these terms when using MATLAB • The length command gives the number of elements in the vector • The magnitude of a vector x having elements x1, x2, …, xn is a scalar, given by √(x12 + x22 + … + xn2), and is the same as the vector's geometric length • The absolute value of a vector x is, in MATLAB, a vector whose elements are the arithmetic absolute values of the elements of x Engineering/Math/Physics 25: Computational Methods 12 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Mag, Length, and Abs-Val Geometric Length Thus the box diagonal a x y z 2 By Pythagoras Find vector a magnitude w 2 x 2 y 2 and a w z 2 2 2 so a2 x2 y2 z 2 Engineering/Math/Physics 25: Computational Methods 13 2 2 >> a =[2,-4,5]; >> length(a) ans = 3 >> % the Magnitude M = norm(a) >> Mag_a = norm(a) Mag_a = 6.7082 >> abs(a) ans = 2 4 5 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt 3D Vector Length Example % Bruce Mayer * ENGR36 % 25Aug09 * Lec03 % file = VectorLength_0908.m % NOTE: using “norm” command is much easier % % Find the length of a Vector AB with %% tail CoOrds = (0, 0, 0) %% tip CoOrds = (2, 1, -5) % % Do Pythagorus in steps vAB = [2 1 -5] % define vector sqs = vAB.*vAB % sq each CoOrd sum_sqs = sum(sqs) % Add all sqs LAB = sqrt(sum_sqs) % Take SQRT of the sumof-sqs Engineering/Math/Physics 25: Computational Methods 14 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt 3D Vector Length Example - Run vAB = 2 1 -5 sqs = 4 1 25 sum_sqs = 30 % Bruce Mayer * ENGR36 % 25Aug09 * Lec03 % file = VectorLength_0908.m % % Find the length of a Vector AB with %% tail CoOrds = (0, 0, 0) %% tip CoOrds = (2, 1, -5) % % Do Pythagorus in steps vAB = [2 1 -5] % define vector sqs = vAB.*vAB % sq each CoOrd sum_sqs = sum(sqs) % Add all sqs LAB = sqrt(sum_sqs) % Take SQRT of the sum-of-sqs LAB = 5.4772 Engineering/Math/Physics 25: Computational Methods 15 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Matrices/Arrays A MATRIX has multiple ROWS and COLUMNS. For example, the matrix M: 2 4 10 16 3 7 M 8 4 9 3 12 15 M contains • FOUR rows • THREE columns VECTORS are SPECIAL CASES of matrices having ONE ROW or ONE COLUMN. Engineering/Math/Physics 25: Computational Methods 16 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Making Matrices For a small matrix you can type it row by row, separating the elements in a given row with spaces or commas and separating the rows with semicolons. For example, typing The Command • >>A = [2,4,10;16,3,7]; Generates Matrix 2 4 10 A 16 3 7 spaces or commas separate elements in different columns, whereas semicolons separate elements in different rows. Engineering/Math/Physics 25: Computational Methods 17 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Making Matrices from Vectors Given Row Vectors: r = [1,3,5] and s = [7,9,11] Combine these vectors to form vector-t and Matrix-D >> r = [1,3,5]; s = [7,9,11]; >> t = [r s] t = 1 3 5 7 9 11 >> D = [r;s] Note the difference D = between the results 1 3 5 7 9 11 given by [r s](or [r,s]) and [r;s] Engineering/Math/Physics 25: Computational Methods 18 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Directly Make Matrix Use COMMAS/SPACES combined with SEMICOLONS to Construct Matrices >> D = [[1,3,5]; [7 9 11]] D = 1 3 5 7 9 11 Note the use of • BOTH Commas and Spaces as COLUMN-Separators • The SEMICOLON as the ROW-Separator Engineering/Math/Physics 25: Computational Methods 19 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt >> r1 = [1:5] Make Matrix Example r1 = 1 2 3 4 5 8 9 10 >> r3 = [11:15] r3 = 11 12 13 14 15 >> r4 = [16:20] r4 = 16 17 18 19 20 21 22 23 24 >> A = [r1;r2;r3;r4;r5] 25 >> r2 = [6:10] r2 = 6 7 >> r5 = [21:25] r5 = A = 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 Engineering/Math/Physics 25: Computational Methods 20 5 10 15 20 25 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Array Addressing The COLON operator SELECTS individual elements, rows, columns, or ''subarrays'' of arrays. Some examples: • v(:) represents all the row or column elements of the vector v • v(2:5) represents the 2nd thru 5th elements; that is v(2), v(3), v(4), v(5). • A(:,3) denotes all the row-elements in the third column of the matrix A. • A(:,2:5) denotes all the row-elements in the 2nd thru 5th columns of A. • A(2:3,1:3) denotes all elements in the 2nd & 3rd rows that are also in the 1st thru 3rd columns. Engineering/Math/Physics 25: Computational Methods 21 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Array Extraction You can use array indices to extract a smaller array from another array. For example, if you first create the array B 2 4 10 13 16 3 7 18 B 8 4 9 25 3 12 15 17 to Produce SubMatrix C type C = B(2:3,1:3) Rows 2&3 Cols 1-3 16 3 7 C 8 4 9 Engineering/Math/Physics 25: Computational Methods 22 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Array Extraction Example A = 1 6 11 16 21 2 7 12 17 22 3 8 13 18 23 4 9 14 19 24 >> C = A(3:5,2:5) C = 12 13 14 17 18 19 22 23 24 15 20 25 Engineering/Math/Physics 25: Computational Methods 23 5 10 15 20 25 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Matrix Commands Command Description Computes the arrays u and v, containing the row and column indices of the NONzero [u,v,w] = elements of the matrix A, and the array w, find(A) containing the values of the nonzero elements. The array w may be omitted. Computes either the number of elements of length(A) A if A is a vector or the largest value of m or n if A is an m × n matrix. Returns a row vector [m n] containing the size(A) sizes of the m x n array A. Engineering/Math/Physics 25: Computational Methods 24 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Matrix Commands cont Command Description * Returns the algebraically largest element in A if A is a VECTOR. * Returns a row vector containing the largest max(A) elements in each Column if A is a MATRIX. * If any of the elements are COMPLEX, max(A) returns the elements that have the largest magnitudes. Similar to max(A) but stores the maximum [x,k] = values in the row vector x and their indices max(A) in the row vector k. Engineering/Math/Physics 25: Computational Methods 25 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Matrix Commands cont Command Description min(A) and [x,k] = Like max but returns minimum values. min(A) Sorts each column of the array A in sort(A) ascending order and returns an array the same size as A. Sums the elements in each column of the sum(A) array A and returns a row vector containing the sums. Engineering/Math/Physics 25: Computational Methods 26 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Examples: Matrix Commands Given Matrix A 6 2 A 10 5 3 7 >> A = [[6,2]; [-10,5]; [3,7]]; >> size(A) ans = 3 2 Engineering/Math/Physics 25: Computational Methods 27 >> length(A) ans = 3 >> max(A) ans = 6 7 >> min(A) ans = -10 2 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt WorkSpace Browser Allows DIRECT access to Variables for editing & changing Engineering/Math/Physics 25: Computational Methods 28 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Array Editor Permits changing of a single Array Value without retyping the entire specification Engineering/Math/Physics 25: Computational Methods 29 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt MultiDimensional (3) Arrays 3D (or more-D) Arrays Consist of twodimensional arrays that ar “layered” to produce a third dimension. • Each “layer” is called a page. 3D pg1 Command pg2 pg3 pg4 Description Creates a new array by cat(n,A,B,C, ...) concatenating the arrays A,B,C, and so on along the dimension n. Engineering/Math/Physics 25: Computational Methods 30 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vectors Digression VECTOR Parameter Possessing Magnitude And Direction, Which Add According To The Parallelogram Law • Examples: Displacements, Velocities, Accelerations SCALAR Parameter Possessing Magnitude But Not Direction • Examples: Mass, Volume, Temperature Vector Classifications • FIXED or BOUND Vectors Have Well Defined Points Of Application That CanNOT Be Changed Without Affecting An Analysis Engineering/Math/Physics 25: Computational Methods 31 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vectors cont. • FREE Vectors May Be Moved In Space Without Changing Their Effect On An Analysis • SLIDING Vectors May Be Applied Anywhere Along Their Line Of Action Without Affecting the Analysis • EQUAL Vectors Have The Same Magnitude and Direction • NEGATIVE Vector Of a Given Vector Has The Same Magnitude but The Opposite Direction Equal Vectors Negative Vectors Engineering/Math/Physics 25: Computational Methods 32 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vector Addition Parallelogram Rule For Vector Addition Examine Top & Bottom of The Parallelogram • Triangle Rule For Vector Addition • Vector Addition is Commutative C B C PQ QP B • Vector Subtraction → Reverse Direction of The Subtrahend P Q P Q Engineering/Math/Physics 25: Computational Methods 33 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vector Addition cont. Addition Of Three Or More Vectors Through Repeated Application Of The Triangle Rule The Polygon Rule For The Addition Of Three Or More Vectors • Vector Addition Is Associative P Q S P Q S P Q S Multiplication by a Scalar • Scales the Vector LENGTH Engineering/Math/Physics 25: Computational Methods 34 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vector Notation In Print and Handwriting We Must Distinguish Between • VECTORS • SCALARS These are Equivalent Vector Notations PPPP • Boldface Preferred for Math Processors • Over Arrow/Bar Used for Handwriting • Underline Preferred for Word Processor Engineering/Math/Physics 25: Computational Methods 35 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Dot Product of 2 Vectors The SCALAR PRODUCT or DOT PRODUCT Between Two Vectors P and Q Is Defined As P Q PQ cos scalar result Scalar-Product Math Properties • ARE Commutative • ARE Distributive • Are NOT Associative PQ Q P P Q1 Q2 P Q1 P Q2 P Q S undefined – Undefined as (P•S) is NO LONGER a Vector Engineering/Math/Physics 25: Computational Methods 36 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Scalar Product – Cartesian Comps Scalar Products With Cartesian Components P Q Px i Py j Pz k Qx i Q y j Qz k >> p = [13,-17,-7]; i i 1 j j 1 k k 1 q = [-16,5,23]; i j 0 j k 0 k i 0 >> pq = dot(p,q) pq = P Q Px Qx Py Q y Pz Qz -454 >> qp = dot(q,p) P P Px2 Py2 Pz2 P 2 MATLAB Makes this Easy with the dot(p,q) Command Engineering/Math/Physics 25: Computational Methods 37 qp = -454 >> r = [1 3 5 7]; t = [8,6,4,2]; >> rt = dot(r,t) rt = 60 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Cross Product TWISTING Power of a Force MOMENTof the Force • Quantify Using VECTOR PRODUCT or CROSS PRODUCT Vector Product Of Two Vectors P and Q Is Defined as The Vector V Which Satisfies: • Line of Action of V Is Perpendicular To the Plane Containing P and Q. • |V| =|P|•|Q|•sinθ • Rt Hand Rule Determines Line of Action for V Engineering/Math/Physics 25: Computational Methods 38 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vector Product Math Properties Recall Vector ADDITION Behaved As Algebraic Addition – BOTH Commutative and Associative. The Vector PRODUCT Math-Properties do NOT Match Algebra. Vector Products • Are NOT Commutative • Are NOT Associative • ARE Distributive P Q Q P P Q P Q NONcommuta tive P Q S P Q S NONassociative P Q1 Q 2 P Q1 P Q 2 Distributi ve Engineering/Math/Physics 25: Computational Methods 39 Q P Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Vector Prod: Rectangular Comps Vector Products Of Cartesian Unit Vectors i i 0 i j k i k j j i k k i j j j 0 k j i j k i k k 0 Vector Products In Terms Of Rectangular Coordinates V P Q Px i Py j Pz k Qx i Qy j Qz k Py Qz Pz Qy i Pz Qx PxQz j PxQy Py Qx k i j k • Summarize Using P Q Px Py Pz Determinate Notation Qx Q y Qz Engineering/Math/Physics 25: Computational Methods 40 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt cross command 3D Vector (Cross) product Evaluation is Painful • c.f. last Slide MATLAB makes it easy with the cross(p,q) command • The two Vectors MUST be 3 Dimensional Engineering/Math/Physics 25: Computational Methods 41 >> p = >> q = >> pxq pxq = -356 >> qxp qxp = 356 [13,-17,-7]; [-16,5,23]; = cross(p,q) -187 -207 = cross(q,p) 187 207 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Array Addition and Subtraction Add/Subtract Element-by-Element p q 17 9 3 11 4 19 28 5 16 8 15 6 6 2 9 AB 10 3 12 14 2 17 Using MATLAB >> p = [17 -9 3]; >> q = [-11,-4,19]; >> p-q ans = 28 -5 -16 Engineering/Math/Physics 25: Computational Methods 42 >> A = [6,-2;10,3]; >> B = [9,8;-12,14]; >> A+B ans = 15 6 -2 17 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Example 2.3-2 x=W y=N 25’ r 20’ w r 55i 36 j 25k −r v = w−r r 55 2 36 2 25 2 v w r w ( r ) v 20 55i 59 36 j 20 25k Engineering/Math/Physics 25: Computational Methods 43 z = Down Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Example 2.3-2 cont x=W y=N r >> r = [55,36,25]; w w = [-20,59,15]; v = w-r >> b = r.*r b = 3025 1296 625 >> c = sum(b) z = Down c = >> v = w-r 4946 v = >> dist1 = sqrt(c) -75 23 -10 dist1 = >> dist2 = 70.3278 sqrt(sum(v.*v)) dist2 = 79.0822 Engineering/Math/Physics 25: Computational Methods 44 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt -r CAVEAT 2D arrays are described as ROWS x COLUMNS • Elemement of D(2,5) – 2 → ROW-2 – 5 → COL-5 ROW Vector → COMMAS COL Vector → SemiColons Engineering/Math/Physics 25: Computational Methods 45 >> r = [4,73,17] r = 4 73 17 >> c = [13;37;99] c = 13 37 99 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Caveat cont Array operations often CONCATENATE or APPEND • This Can Occur unexpectedly • Use the clear command to start from scratch concatenate con·cat·e·nate ( P ) Pronunciation Key (kn-ktn-t, kn-) tr.v. con·cat·e·nat·ed, con·cat·e·nat·ing, con·cat·e·nates 1. To connect or link in a series or chain. 2. Computer Science. To arrange (strings of characters) into a chained list. adj. (-nt, -nt) 1. Connected or linked in a series. Engineering/Math/Physics 25: Computational Methods 46 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt All Done for Today Next Time: More Array Operations Engineering/Math/Physics 25: Computational Methods 47 Matrix Multiplication • Explained in Fine Detail in MATH6 • Some UseFul Links – http://www.mai.liu.se/~halun/mat rix/matrix.html – http://people.hofstra.edu/faculty/ Stefan_Waner/RealWorld/tutoria lsf1/frames3_2.html – http://calc101.com/webMathema tica/matrix-algebra.jspMatrix Multiplication Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Engr/Math/Physics 25 Appendix-1 Vector Math Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 48 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Rectangular Force Components Using Rt-Angle Parallelogram Resolve F into Perpendicular Components F F F x y Define Perpendicular UNIT Vectors Which Are Parallel To The Axes Vectors May then Be Expressed As Products Of The Unit Vectors With The SCALAR MAGNITUDES Of The Vector Components F Fx Fy iFx jFy Engineering/Math/Physics 25: Computational Methods 49 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Adding by Components Find: Resultant of 3+ Forces R PQS Plan: • Resolve Each Force Into Components • Add LIKE Components To Determine Resultant • Use Trig to Fully Describe Resultant iR x jRy iP x jPy iQ x jQy jS x jS y iP x Q x S x jPy Qy S y Engineering/Math/Physics 25: Computational Methods 50 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Adding by Comp. cont. The Scalar Components Of The Resultant Are Equal To The Sum Of The Corresponding Scalar Components Of The Given Forces R x P x Px Q x Fx R y Py Q y S y Fy Use The Scalar Components Of The Resultant to Find the Resultant Magnitude & Direction By Trig R R R 2 x 2 y Engineering/Math/Physics 25: Computational Methods 51 tan 1 Ry Rx Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt 3D Rectangular Components The vector F is contained in the plane OBAC. Resolve F into horizontal and vertical components. FF Fy F cos y Fh F sin y Engineering/Math/Physics 25: Computational Methods 52 Resolve Fh into rectangular components Fx Fh cos F sin y cos Fz Fh sin F sin y sin Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt 3D Rectangular Comp. cont. With the angles between F and the axes Fx F cos x Fy F cos y Fz F cos z F Fx i Fy j Fz k F cos x i cos y j cos z k Fλ λ cos x i cos y j cos z k is a UNIT VECTOR along the line of action of F, and cosx, cosy, and cosz, are the DIRECTION COSINES for F Engineering/Math/Physics 25: Computational Methods 53 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt 2-Pt Direction Cosines Consider Force, F, Directed Between Pts • M(x1,y1,z1) • N(x2,y2,z2) The Vector MN Joins These Points with Scalar Components dx, dy, dz MN d d x i d y j d z k d x x2 x1 d y y2 y1 d z z 2 z1 Engineering/Math/Physics 25: Computational Methods 54 d d d x2 d y2 d z2 1 d x i d y j d z k d Fd y Fd x Fd z Fx Fy Fz d d d dy d d cos x x cos y cos z z d d d F Fλ Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt Engr/Math/Physics 25 Appendix Live Demo Bruce Mayer, PE Licensed Electrical & Mechanical Engineer BMayer@ChabotCollege.edu Engineering/Math/Physics 25: Computational Methods 55 Bruce Mayer, PE BMayer@ChabotCollege.edu • ENGR-25_Arrays-1.ppt