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
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 2009 Dan C Marinescu Office HEC 439 B Office hours Tu Th 11 00 12 00 Lecture 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 Matlab Lecture 5 2 Insight 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 3 A 32 bit word can be used to represent 1 a signed integer 2 a floating point number 3 a string of characters 4 a machine instruction 1 b31 b30 b1 b12 b0 b31 is the sign bit 0 1 positive integer negative integer Magnitude of the signed integer b30 x 230 b29 x 229 b2 x 22 b1 x 21 b0 x 20 2 b31 b30 b24 b23 b22 b21 b1 Exponent Significant Mantissa 7 bit b31 is the sign bit 0 1 b0 24 bit Floating point number 1 signx Significant x 2Exponent positive integer negative integer 8 bit 3 ASCII Character ASCII Character ASCII Character 8 bit 8 bit 4 Opcode 8 bit ASCII Character Addressing Information 24 bit 4 Two 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 2 5 Two 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 10 6 2 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 is positive 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 10 7 Floating 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 38 About 6 to 7 significant digits Double precision representation the Mantissa significant uses 32 24 56 bits About 14 significant digits 8 Arrays 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 commas a 1 2 3 4 5 a 1 2 10 specify the first element the increment and the of elements a 1 3 5 7 9 a 1 3 5 7 9 specify the elements separated by commas or spaces a 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 1 2 5 Lecture 5 9 The 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 3 4 16 5 6 13 7 8 19 9 10 11 11 b The transpose of matrix b ans 2 4 9 16 3 5 6 8 10 13 19 11 7 9 11 c 2 9 3 4 16 5 6 13 7 8 19 9 10 11 11 c 2 5 19 9 3 4 16 6 13 7 8 9 10 11 1 Lecture 5 10 Element 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 b ans 4 81 16 256 36 169 64 361 100 121 b b ans 1 1 1 1 1 1 1 1 1 1 9 25 49 81 121 1 1 1 1 1 Lecture 5 11 How to identify an element of an array b 4 2 element in row 4 column 2 of matrix b ans 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 whos Name Size Bytes Class Attributes b 5x3 120 double Lecture 5 12 Array Creation with Built In Functions zeros r c create an r row by c column matrix of zeros zeros n create an n by n matrix of zeros ones r c create an r row by c column matrix of ones ones n create an n by n matrix one ones help elmat gives a list of the elementary matrices Lecture 5 13 Colon Operator Create a linearly spaced array of points start diffval limit Start first value in the array diffval difference between successive values in the array and limit boundary for the last value Example 1 0 6 3 ans 1 0000 1 6000 2 2000 Lecture 5 2 8000 14 Colon Operator cont d If diffval is omitted the default value is 1 3 6 ans 3 4 5 6 To create a decreasing series diffval must be negative 5 1 2 2 ans 5 0000 3 8000 2 6000 …


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 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?