1
Section 3.3: Basic Calculations
Entering numbers and text Writing an equation Relative versus Fixed Cell References
Previous Slide
Section 3.3: Basic Calculations
Next Slide
Entering numbers
2
Place the cursor in A1 (X) and enter the num
1
Section 3.2: Navigating Excel
Menus,
Tool bars, Sheets
Cells
default and naming Moving from cell to cell
Identity:
Previous Slide
Section 3.2: Navigating Excel
Next Slide
Toolbars and sheets
Main menu tabs Tool bar window
2
Selectin
1
Section 3.1: Microsoft Excel-Getting Started
Excel
is a spreadsheet program Part of the Microsoft Office suite
Probably Can
the most widely used computational tool by engineers and scientists
quickly setup and complete calculations, make t
1
Section 2.13: Double-Indexed (2-D) Arrays
Arrays Part III Double-index notation Uses Calling functions with 2-D arrays as arguments Calculations with 2-D arrays
Previous Slide
Section 2.13: Double-Indexed Arrays
Next Slide
Double vs. Sin
1
Section 2.12: Using Arrays
Arrays Part II
Reading data from a .txt file into an array Reading and skipping text in .txt files
Calling functions with arrays as arguments Calculations with single-indexed arrays
Previous Slide
Section 2.12:
1
Section 1.4: Moving Files
In
Windows Moving vs. Copying Using Email Using ftp
Previous Slide
Section 1.4: Moving Files Around
Next Slide
Moving a file from folder to folder
Open
2
two Folder windows One where the file is, and One wher
1
Section 5.8: Reading From Formatted Files
Skipping
text when using the load function
Using
fscanf
Previous Slide
Section 5.8: Reading From Formatted Files
Next Slide
Reading data from file with text
The To
2
command "load filename.t
1
Section 5.11: Loops - for and while
Not
needed as much as with other languages, because of MatLab's ability to do matrix math loops are useful when running multiple cases
However,
Previous Slide
Section 5.11: Loops - for and while
Next Slid
1
Prompting for keyboard data
To know what data to enter from the keyboard, a program will use a cout statement to "prompt" (i.e. ask) for the data, followed by a cin statement for input of the data. For example:
cout < "Please enter variable1 here:
1
Section 5.12: Writing to Files
Opening Closing
a file and printing to it
a file when finished
Previous Slide
Section 5.12: Writing to Files
Next Slide
A file output example: foutexample.m
output command name that you choose e.g. we use fil
1
Section 1.3 Files and Folders
The
extension of a file tells you its type .cpp = C+ file .docx = MS word 2007 document .pptx = MS powerpoint 2007 file .m = MatLab program file .txt = Text file .xlsx = Excel spreadsheet .xlsm = Excel spread
1
Section 5.13: User Defined Functions
Previous Slide
Section 5.13: User Defined Functions
Next Slide
Functions are separate m-files
Arguments are passed by VALUE!
2
There are two files"mainprogram.m"
The function must be in same folder as th
1
Section 1.2: Learning the material
Recommended
Computers and Operating Systems
- Windows XP Mac OS
PC
Not recommended, but can work using Virtual PC neded
Software
Internet
Explorer MS PowerPoint 2007 Dev-C+ (a C+ compiler) MS Exce
HIT THE F5 KEY TO BEGIN THE NARRATED SLIDE SHOW.
Make sure your speakers are turned on.
After hitting F5 the narration will begin in a few seconds.
Chapter 1.1 Getting Started
1
Chapter 1: Introduction
Section 1.1: An overview
Tips on navigating
1
Section 5.14: MatLab Functions
Built in MatLab function used in our previous examples: sort, max, min, std, mean To see the other data functions available: Type help datafun at > prompt
Previous Slide
Section 5.14: MatLab Functions
Next Sl
1
Section 5.9: Formatted Output
Using
the fprintf function
An
map.m example
Previous Slide
Section 5.9: Formatted Output
Next Slide
Formatted output: map.m example
Program name is map.m
2
These are the first few lines of an m-file map.
1
Section 5.7: Plotting Data
Previous Slide
Section 5.7: Plotting Data
Next Slide
A typical data plotting program
run clear at the start of an m file to clear the workspace of any old variables
2
xdata and ydata vectors
x and y vectors `ro' m
1
Section 5.5: Writing M-Files
Files
have the extension .m That's why we call them m files
are text files and can be read in any text editor. MATLAB has a built in text editor.
They
Previous Slide
Section 5.5: Writing M-Files
Next Slide
M-
1
Section 2.9: Single Result Functions
Functions
Library (header file) functions
<cmath> examples: a=sqrt(10.0); b=cos(3.14159); c=pow(a,b); <iomanip> examples: setw(12) setprecision(3)
User Defined Functions
Single Result Functions
1
Section 5.3: MatLab Command Line Mode
Two
ways to use MatLab
Command
line mode Useful for quick calculations
Programming
mode Useful for large calculations that evolve with time
Previous Slide
Section 5.3: Command Line Mode
Next Slide
1
Section 1.5: The Choice of C+, Excel, and MatLab
Why did we choose C+ to be the introductory language for engineering students?
The course we inherited had already moved to C+ from Fortran.
C+ is an Object Oriented Programming (OOP) language,
1
Section 5.15: MatLab funfuns
funfuns
function functions
written so that another function can call them demonstrate two common MatLab funfuns
uses secant method to find function roots root is sometimes call the zero
numerically solves different
Example 6: average_file_in_out.cpp
1
Example 6: Reading data from/to a text file
include <fstream> header declare input/output commands and file names data.txt
output to text file not written until "endl" encountered
average.txt
Previous Slide
1
Section 4.7: Numerical Differentiation
Differentiation
Analytical
Differentiation of a function yields the derivative Derivative the slope of the function Motivation why? Forward, central and backward difference An example
Numerical
1
Example: The half-life of CO2 in the atmosphere
CO2 balances to determine the magnitude of the greenhouse effect (very complex)
CO2 emissions from anthropogenic sources
e.g. Power plants, cars, fires e.g. Fires, biodegradation, animals
no
1
Section 4.6: Root Finding Using Excel
Excel
has a root finding tool called "Goal Seek" Located under "Data" tab, and "What-If Analysis" Solves for roots of equations can also make use of a "Macro" Located under "Developer" tab Records multip
Simple single result function
1
single_result_1.cpp
declare function: type, name, argument types
call function in main program
define function: type, name, argument variables
function statements
return calculated value to main program
Previou
1
Section 4.5: Root Finding II
More
root finding methods
Newton's
method
Very fast way to find roots Requires taking the derivative of f(x) Can be unstable if `unattended'
Secant
method
Similar to Newton's method, Approximates the d
Single result function using a series solution
1
Determining the sine of an angle using a converging power series A power series determines mathematical and trigonometric functions using powers of the input variable
for example:
exp( x ) 1 x
1
Section 4.4: Root Finding I
Analytical
Successive
Bisection Section
substitution
4.5 Root finding II Newton's method Secant method
Previous Slide
Section 4.4: Root Finding I
Next Slide
The form of the equation is important
Linear
f(