Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15.

Similar presentations


Presentation on theme: "Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15."— Presentation transcript:

1 Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Email: rama.oktavian@ub.ac.id Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15

2 Outlines 1. Microsoft Excel basic function 2. Matrix (basic theory) 3. Matrix operation in excel 4. The application of Matrix in Chem. Eng

3 Basic function Using Relative References Cell references are used in formulas, functions, charts, and other Excel commands.formulascharts By default, a spreadsheet cell reference is relative. What this means is that as a formula or function is copied and pasted to other cells, the cell references in the formula or function change to reflect the function's new location.function

4 Basic function Using Absolute References an absolute cell reference identifies the location a cell or group of cells.cell An absolute cell reference consists of the column letter and row number surrounded by dollar signs ( $ ).columnrow An absolute cell reference is used when you want a cell reference to stay fixed on a specific cell.

5 Basic function Using Mixed references

6 Basic function Entering Relative, Absolute, and Mixed References  To enter a relative reference, type the cell reference as it appears in the worksheet. For example, enter B2 for cell B2  To enter an absolute reference, type $ (a dollar sign) before both the row and column references. For example, enter $B$2  To enter a mixed reference, type $ before either the row or column reference. For example, enter $B2 or B$2 or  Select the cell reference you want to change  Press the F4 key to cycle the reference from relative to absolute to mixed and then back to relative

7 Basic function -Mathematics function - Statistical function - Logical function - etc

8 Basic function Mathematics functions abs(CELL): Absolute value of CELLAbsolute value sqrt(CELL): Square root of CELL [to do nth roots, use CELL^(1/n)]Square root ln(CELL): Natural log of CELLNatural log log10(CELL): Log of CELL to base 10 log(CELL, NUM): Log of CELL to the base NUM (use for all bases except e and 10) exp(CELL): Exponential(e^x) of CELL. Use since Excel doesn't have a built- in constant "e".Exponential sin(CELL), cos(CELL), tan(CELL): Trigonometric functions sine, cosine, and tangent of CELL. CELL must be in radiansTrigonometric functions asin(CELL), acos(CELL), atan(CELL): Inverse trigonometric functions (returns values in radians)Inverse trigonometric functions sinh(CELL), cosh(CELL), tanh(CELL): Hyperbolic functionsHyperbolic functions asinh(CELL), acosh(CELL), atanh(CELL): Inverse hyperbolic functions

9 Basic function Statistical functions average(CELL1, CELL2,...) OR average(GROUP): Computes the arithmetic average of all inputs intercept(GROUP1, GROUP2): Calculates the y-intercept (b) of the regression line where y = GROUP1 and x = GROUP2 slope(GROUP1, GROUP2): Calculates the slope (m) of the regression line where y = GROUP1 and x = GROUP2.

10 “if” function Working with Logical Functions  A logical function is a function that works with values that are either true or false  The IF function is a logical function that returns one value if the statement is true and returns a different value if the statement is false  IF(logical_test, value_if_true, [value_if_false])

11 “if” function Working with Logical Functions A comparison operator is a symbol that indicates the relationship between two values

12 “if” function Working with Logical Functions  =IF(A1="YES", "DONE", "RESTART")  =IF(A1="MAXIMUM", MAX(B1:B10), MIN(B1:B10))  =IF(D33>0, $K$10, 0)

13 “if” function Working with Logical Functions

14 Matrix (basic theory) Matrix Mathematics  Matrices are very useful in engineering calculations. For example, matrices are used to: - Efficiently store a large number of values -Solve systems of linear simultaneous equations  Several mathematical operations involving matrices are important

15 Matrix (basic theory) Review: Properties of Matrices An element of a matrix is usually written in lower case, with its row number and column number as subscripts: The dimension (size) of a matrix is defined by the number of rows and number of columns Examples: 3 × 3:2×4:

16 Matrix (basic theory) Matrix Operations Matrix Addition Multiplication of a Matrix by a Scalar Matrix Multiplication Matrix Transposition Finding the Determinate of a Matrix Matrix Inversion

17 Matrix (basic theory) Matrix Addition Vectors must be the same size in order to add To add two vectors, add the individual elements: Matrix addition is commutative: A + B = B + A

18 Matrix (basic theory) Multiplication of Matrices To multiple two matrices together, the matrices must have compatible sizes: This multiplication is possible only if the number of columns in A is the same as the number of rows in B The resultant matrix C will have the same number of rows as A and the same number of columns as B

19 Matrix (basic theory) Multiplication of Matrices Consider these matrices: Can we find this product? Yes, 3 columns of A = 3 rows of B What will be the size of C? 2 X 2: 2 rows in A, 2 columns in B

20 Matrix (basic theory) Example – Matrix Multiplication Solution: In general, matrix multiplication is not commutative: AB ≠ BA

21 Matrix (basic theory) Transpose of a Matrix The transpose of a matrix by switching its row and columns The transpose of a matrix is designated by a superscript T:

22 Matrix (basic theory) Determinant of a Matrix The determinant of a square matrix is a scalar quantity that has some uses in matrix algebra. Finding the determinate of 2 × 2 and 3 × 3 matrices can be done relatively easily: The determinate is designated as |A| or det(A) 2 × 2:

23 Matrix (basic theory) Determinant of a Matrix 3 × 3:

24 Matrix (basic theory) Inverse of Matrix The inverse of a 2X2 matrix is easy to find:

25 Matrix (basic theory) The identity matrix a square matrix with 1’s as the diagonal elements and 0’s as the other elements Find A -1, check that A A -1 = I

26 Matrix Operations in Excel Excel has commands for: Multiplication (mmult) Transpose (transpose) Determinate (mdeterm) Inverse (minverse) Important to remember that these commands apply to an array of cells instead of to a single cell When entering the command, you must identify the entire array where the answer will be displayed Using the Enter key with an array command only returns an answer in a single cell. Instead, use Ctrl + Shift + Enter keys with array functions

27 Matrix Operations in Excel Excel Matrix Multiplication

28 Matrix Operations in Excel Excel Matrix Multiplication The MMULT function has two arguments: the ranges of cells to be multiplied. Remember that the order of multiplication is important.

29 Matrix Operations in Excel Excel Transpose

30 Matrix Operations in Excel Excel Determinate

31 Matrix Operations in Excel Excel Matrix Inversion Remember that only square matrices can have inverses

32 Matrix Operations in Excel Excel Matrix Inversion A X A -1 = I, the identity matrix:

33 The application of Matrix Solving linear simultaneous equation If equations contain only linear terms of the independent variables – that is, only constants multiplied by each variable – and constants, then the equation is linear If the equation contains any terms such as x 2, cos(x), e x, etc., then the equation is non-linear Linear simultaneous equation

34 The application of Matrix Solution to Simultaneous Equations Graphical solution Substitution method Elimination method

35 The application of Matrix Equations in Matrix Form The first step in using matrix methods to solve a series of linear simultaneous equations is to write them in matrix form For n simultaneous equations and n unknowns: where A is the coefficient matrix (n × n); X is the matrix of unknowns (n × 1), and C is the constant matrix (n × 1)

36 The application of Matrix Solution of System of Linear Equations  Multiply both sides of the equation by the inverse of the coefficient matrix. Remember that the order of multiplication is important.  Since the inverse of a matrix times that matrix is equal to the identity matrix,

37 The application of Matrix Solution of System of Linear Equations  Since the identity matrix times another matrix is equal to that matrix,  Therefore, we can find the unknown variables by multiplying the inverse of the coefficient matrix by the constant matrix

38 The application of Matrix Example – 3 Equations Write these equations in matrix form:

39 The application of Matrix Excel Solution Enter coefficient and constant matrices:

40 The application of Matrix Excel Solution Enter formula to invert A matrix and multiply the result by the C matrix. This can be done in two steps or with nested commands as shown here:

41 The application of Matrix Chem. Eng Problem Steady state material balances on a separation train Xylene, styrene, toluene and benzene are to be separated with the array of distillation columns that is shown below where F, D, B, D1, B1, D2 and B2 are the molar flow rates in mol/min.

42 The application of Matrix Chem. Eng Problem Solution Material balances on individual components on the overall separation train yield the equation set

43 The application of Matrix

44


Download ppt "Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W. 13-15 Th. 13-15, F. 13-15."

Similar presentations


Ads by Google