Section 1
Engineering Problem Solving
Engineering often involves applying a consistent, structured approach to the solving of problems. A general problem-solving approach and method can be dened, although variations will be required for specic problems. P
Section 2
Matlab Technical Computing Environment
Matlab provides a technical computing environment designed to support the implementation of computational tasks. Briey, Matlab is an interactive computing environment that enables numerical computation and
Determine what question is to be answered and what output or results are to be produced. Determine what theoretical and experimental knowledge can be applied. Determine what input information or data is available Many academic problems that you will be a
Graphics (Figure) window Display plots and graphs Created in response to graphics commands M-le editor/debugger window Create and edit scripts of commands called M-les When you begin Matlab, the command window will be the active window. As commands are e
Develop an algorithm, or step-by-step method of evaluating the equations involved in the solution. Describe the algorithm in mathematical terms and then implement as a computer program. Carefully review the proposed solution, with thought given to altern
Mathematical construct that has a value or set of values. Constructed from numbers, operators, and variables. Value of an expression found by typing the expression and pressing Enter
2.2.1
Numbers
Matlab represents numbers in two form, xed point and oati
The program should be executed on obtained or computed test data for which the answer or solution is either known or which can be obtained by independent means, such as hand or calculator computation. Intermediate values should be compared with expected
ans = 7 > 3 - 3 ans = 0 > 4/5 ans = 0.8000 Prompt > is supplied by Matlab, indicates beginning of the command. ans = following the completion of the command with the Enter key marks the beginning of the answer. Operations may be chained together. For exam
Output or results to be produced: It is clear from the problem statement that the results to be produced are the time of ight and the distance traveled. The units for these quantities havent been specied, but from our knowledge of throwing a baseball, co
Matlab cannot make sense out of just any command; commands must be written using the correct syntax (rules for forming commands). Compare the interaction above with > 4 + 6 + ? 4 + 6 + | Missing operator, comma, or semi-colon. Here, Matlab is indicating t
3. Computational Method: Using the model developed above, expressions for the desired results can be obtained. The object will hit the ground when its vertical position is zero 1 y (t) = vt sin gt2 = 0 2 which can be solved to yield two values of time t =
When a command of this form is executed, the expression is evaluated, producing a number that is assigned to the variable. The variable name and its value are displayed. If a variable name is not specied, Matlab will assign the result to the default varia
Words following percent signs (%) are comments to help in reading the Matlab statements. A word on the left of an equals sign is known as a variable name and it will be assigned to the value or values on the right of the equals sign. Commands having this
> x=2 x= 2 > y=x+5 y= 7 If you have not supplied a value for x, Matlab will return a syntax error: > y=x+5 ? Undefined function or variable x. Precedence of operations involving variables Consider the computation of the area of a trapezoid whose parallel
Flight Trajectory 30 Height (ft) 20 10 0
0
50 Distance (ft)
100
150
Figure 1.2: Matlab generated plot of ight trajectory
1.2.1
Programming Style
Programs that are not documented internally, while they may do what is request, can be dicult to understand wh
Matlab would rst compute TF-32, replacing it with a value. Then 5/9 would be computed and this value would multiply the previously computed value of TF-32. Easier to understand: TC = (5/9)*(TF-32) Use multiple statements Consider the equation: H (s) = s2
An interface between the user and the hardware An environment for developing, selecting, and executing software. The operating system is the most important part of the systems software, managing the computer resources, including: The individual user sess
Language is closely tied to the hardware design. Machine specic: machine language for one computer is dierent from that of a computer having a dierent hardware design. Assembly language: Also unique to a specic computer design. Commands or instructions a
> items = screws + bolts + rivets items = 94
Command reuse and editing Commands can be reused and editted using the following operations: Press the up arrow cursor key () to scrolls backward through previous commands. Press Enter to execute the selected c
These program errors are caused when the programmer errs in determining the correct steps to be taken in the problem solution, such as an attempt to divide by zero. These errors must be corrected in the source program, which must again be compiled and li
Commas and semicolons can be used to place multiple commands on one line, with commas producing display of results, semicolons supressing Percent sign (%) begins a comment, with all text up to the next line ignored by Matlab Three periods (. . .) at the
When a command is entered that doesnt meet the command rules, an error message is displayed. The corrected command can then be entered. Use of this environment doesnt require the compile-link/load-execution process described above for high-level language
Information about these functions is displayed by the command help function. For example: > help sqrt SQRT Square root. SQRT(X) is the square root of the elements of X. Complex results are produced if X is not positive. See also SQRTM. Example 2.5 Use of
Echo: To display commands or other input typed by the user. Print: To output information on a computer printer (often confused with display in the textbook).
13
To solve, complete the square in s s+ b 2a
2
b 2a
2
+
c =0 a
Rewrite to leave only the term involving s on the left hand side s+ b 2a
2
=
1 2a
2
b2 4ac
Take the square root of each side to nd the solutions s1,2 = 1 b 2a 2a b2 4ac
There are two solutions,
Fixed-Point Numbers All computer instructions and data are represented and stored in binary (base 2) form. In the representation of xed-point numbers, the value of each digit in the number depends on its position relative to the xed decimal point. For exa
If y is not a member of the set of oating-point numbers, we say that x is not representable in the oating-point number system. This can happen if x is too large, which is called overow error; or if the absolute value of x is too small, which is called an
> z = x*y z= 0 Here z should have been 2.5e-400, but due to exponent underow, the result is displayed as 0. Due to the nite accuracy of the representation of numbers in a computer, errors can be made in computations. For example, we know that 1 5 0.2 = 0;
> 610./12. ans = 50.8333 Short oating point: When the result has more than three digits to the left of the decimal point, it is displayed in scientic notation (called the short e format). Scientic notation expresses a value as a number between 1 and 10 mu