Functions

1 / 19

# Functions - PowerPoint PPT Presentation

Functions. http://www2.warwick.ac.uk/fac/sci/moac/degrees/modules/tutorial/matlab. Review. Script files Run a list of commands Flow Control If, for, while, etc. Functions. All variables are local variables. Example. Fibonacci Sequence.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Functions' - stacia

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
http://www2.warwick.ac.uk/fac/sci/moac/degrees/modules/tutorial/matlabhttp://www2.warwick.ac.uk/fac/sci/moac/degrees/modules/tutorial/matlab
Review
• Script files
• Run a list of commands
• Flow Control
• If, for, while, etc
Functions
• All variables are local variables
Fibonacci Sequence
• Write a function that calculates the nth number in the Fibonacci Sequence
Multiple inputs and outputs
• Comments + good layout make things easier to read, correct, use and re-use.
Solving Equations
• Write a function that solves
• For real roots, otherwise displays an error.
• Also creates a plot of this function.
• And displays the real roots.

Inputs:

• Length of pendulum
• Starting pendulum angle
• Hints:
• To start just draw the pendulum in its starting position
• Use Euler rule