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

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

View Full Document Right Arrow Icon
Chapter 3 Programming with MATLAB
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 - - + = + +
Background image of page 2
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!
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/15/2010 for the course EGM 5403 taught by Professor Mei during the Spring '10 term at University of Florida.

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 Right Arrow Icon
Ask a homework question - tutors are online