DOC PREVIEW
UCF EGN 3420 - Lecture Notes

This preview shows page 1-2-3-24-25-26 out of 26 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 26 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Engineering Analysis ENG 3420 Fall 2009Lecture 5Insight not numbers!!Two’s complement representation of signed integersTwo’s complement representations of integers2’s complement of signed integersFloating point numbersArraysThe transpose of an arrayElement by element array operationsHow to identify an element of an arrayArray Creation – with Built In FunctionsColon OperatorColon Operator (cont’d)Array Creation - linspaceArray Creation - logspaceArithmetic operations on scalars and arraysComplex numbersVector-Matrix CalculationsHelp built-in functionElement-by-Element CalculationsM-files; Script and Function FilesFunction File SyntaxQuadratic equationsMatlab program for solving quadratic equationsEngineering Analysis ENG 3420 Fall 2009Dan C. MarinescuOffice: HEC 439 BOffice hours: Tu-Th 11:00-12:002Lecture 5Lecture 5 Last time:  Applications of Laplace Transform for solving differential equations. Example. Today: Internal representations of numbers and characters in a computer. Arrays in Matlab Matlab program for solving a quadratic equation Next Time Roundoff and truncation errors More on Matlab3Insight not numbers!! Engineering requires a quantitative analysis (ultimately some numbers) but the purpose of engineering analysis is to gain insight not numbers!!  Engineering analysis is based on concepts from several areas of math and statistics: Calculus (integration, differentiation, series) Complex analysis  Differential equations Linear algebra Probability and statistics The purpose of this class is not to teach you Matlab, but to teach you how to use Matlab for solving engineering problems. Matlab is just a tool, an instrument. What good is to have a piano without being taught how to play…. One must be familiar with the software tools but understand the math behind each method.4A 32-bit word can be used to represent:1. a signed integer2. a floating point number3. a string of characters4. a machine instructionb0b1b31b30b31is the sign bit:0 positive integer1 negative integerMagnitude of the signed integer= b30 x 230+ b29 x 229+……..+.b2 x 22+.b1 x 21+.b0 x 20b12b0b1b31b30b23b22b21Exponentb31is the sign bit:0 positive integer1 negative integerSignificant/Mantissab24Floating point number= (-1)signx Significant x 2Exponent123 ASCII Character ASCII Character ASCII Character ASCII CharacterAddressing Information4 Opcode8 bit8 bit8 bit8 bit7 bit 24 bit24 bit5Two’s complement representation of signed integers The 2’s complement representation of a positive integer is the binary representation of the integer. For example: (0000 0000 0000 0000 0000 0000 0000 0010)2= 210 negative integer is obtained by subtracting the binary represntaton of the integer from a large power of two (specifically, from 2N for an N-bit two's complement) and the andding 1  Example: N=32 Î the 2’s complement of (-2)(1111 1111 1111 1111 1111 1111 1111 1111)2 - (0000 0000 0000 0000 0000 0000 0000 0010)2= (1111 1111 1111 1111 1111 1111 1111 1101)2(1111 1111 1111 1111 1111 1111 1111 1101)2+(0000 0000 0000 0000 0000 0000 0000 0001)2= (1111 1111 1111 1111 1111 1111 1111 1110)26Two’s complement representations of integers(0000 0000 0000 0000 0000 0000 0000 0000)2= 010(0000 0000 0000 0000 0000 0000 0000 0001)2= 110(0000 0000 0000 0000 0000 0000 0000 0010)2= 210…………………….(0111 1111 1111 1111 1111 1111 1111 1110)2= (2,147,483,646)10(0111 1111 1111 1111 1111 1111 1111 1111)2= (2,147,483,647)10(1000 0000 0000 0000 0000 0000 0000 0000)2= -(2,147,483,648)10(1000 0000 0000 0000 0000 0000 0000 0001)2= -(2,147,483,647)10(1000 0000 0000 0000 0000 0000 0000 0010)2= -(2,147,483,646)10…………………….(1111 1111 1111 1111 1111 1111 1111 1110)2= -(2)10(1111 1111 1111 1111 1111 1111 1111 1111)2= -(1)1072’s complement of signed integers The advantages of two-s complement representation: All negative numbers have the leftmost bit equal to 1 thus the hardware needs only to check one bit to determine if a number ispositive or negative. When 32 bits are used to represent signed integers the range is: from -(2,147,483,648)10 to (2,147,483,64t)108Floating point numbers The range is limited. For example, with 32 bit the single precision representation allows us to represent floating point numbers in the range:2.0 x 1038 - 2.0 x 10-38About 6 to 7 significant digits. Double precision representationÎ the Mantissa (significant) uses 32+24 = 56 bits. About 14 significant digits.9Lecture 5Arrays In addition to scalars, we can use vectors (one-dimensional arrays), or matrices (two-dimensional arrays). Examples:>> a = [1 2 3 4 5 ] % specify the elements of the array individually separated by spaces or commasa =1 2 3 4 5>> a =1:2:10 % specify, the first element, the increment, and the # of elementsa =1 3 5 7 9>> a=[1 3 5 7 9] % specify the elements separated by commas or spacesa =1 3 5 7 9 Arrays are stored column wise (column 1, followed by column 2, etc.). A semicolon marks the end of a row. >> a=[1;2;3]a =12510Lecture 5The transpose of an array The transpose (‘) operator transform rows in columns and columns in rows;>> b = [2 9 3 ;4 16 5 ;6 13 7 ;8 19 9;10 11 11]b =2 9 34 16 56 13 78 19 910 11 11>>b' % The transpose of matrix bans =2 4 6 8 109 16 13 19 113 5 7 9 11>> c = [2 9 3 4 16; 5 6 13 7 8; 19 9 10 11 11]c =2 9 3 4 165 6 13 7 819 9 10 11 111Lecture 5Element by element array operations Both arrays must have the same number of elements.(1) multiplication (“.*”) (2) division (“./”) and (3) exponentiation (notice the “.” bfefore “*”, “/”, or “^”). >> b.* bans =4 81 916 256 2536 169 4964 361 81100 121 121>> b ./ bans =1 1 11 1 11 1 11 1 11 1 112Lecture 5How to identify an element of an array>> b(4,2) % element in row 4 column 2 of matrix bans =19>> b(9) % the 9-th element of b (recall that elements are stored column wise)ans =19>> b(5) % the 5-th element of b (recall that elements are stored column wise)ans =10>> b(17)??? Attempted to access b(17); index out of bounds because numel(b)=15. >> whosName Size Bytes Class Attributesb 5x3 120 double13Array Creation – with


View Full Document

UCF EGN 3420 - Lecture Notes

Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?