{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture 7

# Lecture 7 - Chapter 3 Programming with MATLAB Numerical...

This preview shows pages 1–6. Sign up to view the full content.

Chapter 3 Programming with MATLAB

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Newton’s Second Law Euler’s method To obtain good accuracy, it is necessary to use many small steps Extremely laborious and time-consuming to implement by hand Numerical Solution 2 d 2 d v m c g dt dv v c mg dt dv m - = - = ) ( ) ( ) ( ) ( i 1 i 2 i d i 1 i t t t v m c g t v t v - - + = + +
M-Files: Scripts and Functions You can create and save code in text files using MATLAB Editor/Debugger or other text editors (called m-files since the ending must be .m) M-file is an ASCII text file similar to FORTRAN or C source codes ( computer programs) A script can be executed by typing the file name, or using the “ run ” command Difference between scripts and functions Scripts share variables with the main workspace Functions DO NOT share!

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Script Files Script file – a series of MATLAB commands saved on a file, can be executed by: typing the file name in the Command Window invoking the menu selections in the Edit Window: Debug, Run hitting F5 key in Edit Window Create a script file using menu selection: File, New, M-file
Compute the velocity of a free-falling bungee jumper at a specific time Open the editor with: File, New, M-file Save the file as bungee_jumper.m Type bungee_jumper in command window Script File – Bungee Jumper g = 9.81; m = 68.1 ; t = 20; cd = 0.25; v = sqrt(g*m/cd) * tanh(sqrt(g*cd/m)*t) » bungee_jumper v = 51.6416 Type the name of the script file

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 19

Lecture 7 - Chapter 3 Programming with MATLAB Numerical...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online