MATLAB Programming - David Kuncicky.pdf

(2373 KB) Pobierz
master.dvi
Contents
1 Engineering Problem Solving
1
1.1 Problem-SolvingProcess.................................. 1
1.2 ProblemSolvingExample................................. 4
1.3 Computing Software . ................................... 8
1.4 Computing Terminology. . . ............................... 12
2
Matlab
Technical Computing Environment
14
2.1 Workspace,Windows,andHelp.............................. 14
2.2 ScalarMathematics .................................... 15
2.3 BasicMathematicalFunctions............................... 24
2.4 Computational Limitations . ............................... 26
2.5 DisplayOptions....................................... 29
2.6 Accuracyand Precision . . . ............................... 33
3 Files and File Management
37
3.1 FileManagementDefinitionsandCommands ...................... 37
3.2 SavingandRestoringMatlabInformation........................ 39
3.3 ScriptM-Files........................................ 43
3.4 ErrorsandDebugging ................................... 47
3.5 MatlabSearchPath,PathManagement,andStartup.................. 49
i
4 Trigonometry and ComplexNumbers
51
4.1 Trigonometry........................................ 51
4.2 ComplexNumbers ..................................... 57
4.3 Two-DimensionalPlotting................................. 72
5 Arrays and Array Operations
81
5.1 VectorArrays........................................ 81
5.2 MatrixArrays........................................ 88
5.3 ArrayPlotting Capabilities . ............................... 93
6 Mathematical Functions and Applications
101
6.1 SignalRepresentation,Processing,andPlotting.....................101
6.2 Polynomials.........................................111
6.3 PartialFractionExpansion ................................120
6.4 FunctionsofTwoVariables ................................125
6.5 User-DefinedFunctions ..................................129
6.6 PlottingFunctions .....................................133
7DataAnalys
135
7.1 MaximumandMinimum..................................136
7.2 SumsandProducts.....................................140
7.3 StatisticalAnalysis.....................................143
7.4 RandomNumberGeneration ...............................148
8 Selection Programming
155
8.1 RelationalandLogicalOperators.............................155
8.2 FlowControl ........................................161
8.3 Loops ............................................165
8.4 SelectionStatementsinUser-DefinedFunctions.....................169
8.5 UpdateProcesses......................................171
ii
8.6 AppliedProblemSolving:SpeechSignalAnalysis....................175
9 Vectors, Matrices and Linear Algebra
180
9.1 Vectors ...........................................181
9.2 Matrices...........................................187
9.3 SolutionstoSystemsofLinearEquations ........................196
9.4 AppliedProblemSolving:RobotMotion.........................202
10 Curve Fitting and Interpolation
207
10.1MinimumMean-SquareErrorCurveFitting.......................207
10.2 Applied Problem Solving: Hydraulic Engineering . ...................213
10.3Interpolation ........................................215
10.4AppliedProblemSolving:HumanHearing........................219
11 Integration and Differentiation
223
11.1NumericalIntegration ...................................223
11.2 Numerical Differentiation . . ...............................230
12 Strings, Time, Base Conversion and Bit Operations
239
12.1CharacterStrings......................................239
12.2 Time Computations . ...................................244
12.3BaseConversionsandBitOperations...........................247
13 Symbolic Processing
250
13.1SymbolicExpressionsandAlgebra ............................250
13.2ManipulatingTrigonometricExpressions.........................257
13.3EvaluatingandPlottingSymbolicExpressions .....................258
13.4SolvingAlgebraicandTranscendentalEquations ....................259
13.5Calculus...........................................262
13.6LinearAlgebra .......................................266
iii
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 defined, although variations will be required
for specific problems.
Problems must be approached methodically, applying an algorithm , or step-by-step procedure by
which one arrives at a solution.
1.1 Problem-Solving Process
The problem-solving process for a computational problem can be outlined as follows:
1. Define the problem.
2. Create a mathematical model.
3. Develop a computational method for solving the problem.
4. Implement the computational method.
5. Test and assess the solution.
The boundaries between these steps can be blurred and for specific problems one or two of the
steps may be more important than others. Nonetheless, having this approach and strategy in mind
will help to focus our efforts as we solve problems
1. Problem Definition:
The first steps in problem solving include:
Recognize and define the problem precisely by exploring it thoroughly (may be the most
di.cult step).
1
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 asked to solve have this step completed by the instructor.
For example, if your instructor ask you to solve a quadratic algebraic equation and provides you
with all of the coe.cients, the problem has been completely defined before it is given to you and
little doubt remains about what the problem is.
If the problem is not well defined, considerable effort must be expended at the beginning in studying
the problem, eliminating the things that are unimportant, and focusing on the root problem. Effort
at this step pays great dividends by eliminating or reducing false trials, thereby shortening the time
taken to complete later steps.
After defining the problem:
Collect all data and information about the problem.
Verify the accuracy of this data and information.
Determine what information you must find: intermediate results or data may need to be
found before the required answer or results can be found.
2. Mathematical Model:
To create a mathematical model of the problem to be solved:
Determine what fundamental principles are applicable.
Draw sketches or block diagrams to better understand the problem.
Define necessary variables and assign notation.
Reduce the problem as originally stated into one expressed in purely mathematical terms.
Apply mathematical expertise to extract the essentials from the underlying physical descrip-
tion of the problem.
Simplify the problem only enough to allow the required information and results to be obtained.
Identify and justify the assumptions and constraints inherent in this model.
3. Computational Method:
A computational method for solving the problem is to be developed, based on the mathematical
model.
Derive a set of equations that allow the calculation of the desired parameters and variables.
2
Zgłoś jeśli naruszono regulamin