Lecture 4. Programming

Size: px
Start display at page:

Download "Lecture 4. Programming"

Transcription

1 Lecture 4 Advanced Matlab Programming

2 Announcements Hands-on Session on Friday 1318 EB Read Chapters 3-6 in your MATLAB book HW 2 opens up Friday evening

3 Today Numerical analysis - I Visualization I Some more programming

4 Advanced Matlab Programming Functions Can have variable number of inputs and outputs (see: nargin, nargout, varargin, varargout) Can have internal functions Data types: more than just arrays and strings: Structures Cell arrays File handling Supports most C-commands for file I/O (fprintf, )

5 MATLAB Compiler Converts function M-files to C or C++ source code (and executables) Uses native compiler to create executables Creates MEX-file from function M-file, e.g. function.m >>mcc x function Creates stand-alone a executable ecutab e from function M-file >>mcc m function

6 Matlab Compiler

7 Matlab Compiler

8 Visualization Matlab is great for plotting functions x = [0:0.01:2*pi]; y = cos(x); () plot(x,y)

9 Visualization Add titles to graphs and axis title( this is the title ) xlabel( x ) x ylabel( y )

10 Visualization Multiple plots plot(x,y1, b-,x,y2, r: ) legend( y1, y2 )

11 Visualization Matlab can also do 3D plots, such as mesh surfaces: [X,Y] = meshgrid(-2:.2:2, -2:.2:2); Z = X.* exp(-x.^2 - Y.^2); mesh(x,y,z)

12 Visualization Or simple 3D plots: x = -2:.02:2; y = x; z = x.* exp(-x.^2 - y.^2); Plot3(x,y,z,. )

13 Visualization All calls to plot, plot3, mesh, etc. will overwrite on the current figure. Make sure that you want to erase the current figure. To create a new empty figure, use the command figure

14 Visualization Adding figures to reports: Print the figure directly Save it to a TIFF file and add to the report (File Export ) Copy to clipboard and paste to the report (Edit Copy Figure) The background is copied too! By default it is gray. e bac g ou d s cop ed oo y de au s g ay To change the background color use: set(gcf, color, white )

15 Save and Load functions save <filename> saves everything in the workspace (or the function variable space) to <filename>.mat. mat If no <filename> is given, saves to matlab.mat. load <filename> loads the file.

16 Advanced Read and Write For formatted read and write, learn how to use the fucntions: fprintf fscanf fopen fclose >> x = 0:.1:1; >> y = [x; exp(x)]; >> fid = fopen('exp.txt','w'); t' ' ') >> fprintf(fid,'%6.2f %12.8f\n',y); >> fclose(fid)

17 Numerical Methods Finding roots of equations Solving matrices (Linear Algebra) Regression / Curve-fitting Numerical Integration Solving ODE s More advanced topics ( solving PDEs) for later

18 Numerical Integration Use the routines trapz, quad >> help trapz >> help quad (Simpson s Rule) Other useful functions: SUM, CUMSUM, DBLQUAD, TRIPLEQUAD

19 Examples: Evaluate the following definite integrals

20

21 Initial Value Problems (IVPs) Very important topic a large number of practical problems in science and engineering g fall into this category The solution of IVPs (and most ODEs in general) can be challenging g if you do not have the right tools Most realistic systems involve ODEs that must be solved numerically MATLAB has a suite of tools (e.g., ode45)

22 Examples Imagine you parachute out of a plane v = downward velocity m = mass C = drag coefficient ce Initial Condition: v(0) = 0 dv m mg Cv dt = 2

23 Microbial uptake To describe microbial utilization of a substrate: dc X C = k a dt K + C S

24 Systems of Differential Equations dy dt dy dt dy dt dy n dt y1(0), y2(0), y3(0) are known = f (, t y, y, y y ) = f (, t y, y, y y ) = (,,, ) f t y 1 y 2 y 3 y n = f (, t y, y, y y ) n n n

25 The Runge-Kutta Algorithm Consider the simple first order equation: dy = f(, t y) dt y (0) = a y = k 1 y + + k δ1 δ2 δ3 δ δ =Δtf( t, y) 1 k k 1 1 δ2 =Δ tf ( tk + Δ t, yk + δ1) δ 3 = Δ t f ( t k + Δ t, y k + δ 2 ) 2 2 δ =Δ tf( t +Δ t, y + δ ) 4 k k 3

26 y k Example 1 dy 2 3 Solve: = 2y + e dt y (0) = 1 = y + k δ δ δ δ δ t t t 1 =Δ f y =Δ y + t 2 ( k, k ) 2 k exp( 3 k) δ2 =Δ tf( tk + Δ t, yk + δ1) =Δt 2 yk + δ1 + exp( 3 tk + Δt ) δ3 =Δ tf( tk + Δ t, yk + δ2) =Δt 2 yk + δ2 + exp( 3 tk + Δt ) t 2 ( ) ( ) δ4 =Δ tf( tk +Δ t, yk + δ3) Δt 2 yk + δ3 + exp( 3 tk +Δt )

27 eek! too many details!

28 The same thing in MATLAB Suppose you want to solve the DE: dy 2 2y exp( 3 t); y(0) 1 from t =0 to 5; dt = + = Step 1 Create a function (an.m m file) called myode.m m with the 2 lines function dydt=myode(t,y); dydt=-2*y^2+exp(-3*t); Step 2 Type the following command in MATLAB: [t,y]=ode45('myode',[0,5],1); plot(t,y); Quite Simple, my dear Watson! Adventures of Sherlock Holmes --Sir Arthur Conan Doyle

29 Solving a system of two differential equation (DE) using MATLAB: Two Lakes in Series (Chapra, page 128) dc 1 dt dc2 dt = λ c 11 1 = λ c λ c Step1. Create the function twolakes.m function [ypr] = twolakes(t,y); ypr = zeros(2,1); % This is important! It preallocates a vector with two elements for c1 and c2. ypr(1)=-2.0*y(1); ypr(2)=1.667*y(1)-1.667*y(2); Step2: Type in MATLAB: >> tspan = [0 1]; y0 = [10,0.0];[t,y]=ode45('twolakes',tspan,y0);plot(t,y);

OKLAHOMA STATE UNIVERSITY

OKLAHOMA STATE UNIVERSITY OKLAHOMA STATE UNIVERSITY ECEN 4413 - Automatic Control Systems Matlab Lecture 1 Introduction and Control Basics Presented by Moayed Daneshyari 1 What is Matlab? Invented by Cleve Moler in late 1970s to

More information

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP MATLAB sessions: Laboratory 4 MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP In this laboratory session we will learn how to. Use MATLAB solvers for solving scalar IVP 2. Use MATLAB solvers for

More information

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP In this laboratory session we will learn how to. Use MATLAB solvers for solving scalar IVP 2. Use MATLAB solvers for solving higher order ODEs and

More information

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP

MAT 275 Laboratory 4 MATLAB solvers for First-Order IVP MAT 75 Laboratory 4 MATLAB solvers for First-Order IVP In this laboratory session we will learn how to. Use MATLAB solvers for solving scalar IVP. Use MATLAB solvers for solving higher order ODEs and systems

More information

Chapter 9b: Numerical Methods for Calculus and Differential Equations. Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers

Chapter 9b: Numerical Methods for Calculus and Differential Equations. Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers Chapter 9b: Numerical Methods for Calculus and Differential Equations Initial-Value Problems Euler Method Time-Step Independence MATLAB ODE Solvers Acceleration Initial-Value Problems Consider a skydiver

More information

Lab 13: Ordinary Differential Equations

Lab 13: Ordinary Differential Equations EGR 53L - Fall 2009 Lab 13: Ordinary Differential Equations 13.1 Introduction This lab is aimed at introducing techniques for solving initial-value problems involving ordinary differential equations using

More information

AMS 27L LAB #8 Winter 2009

AMS 27L LAB #8 Winter 2009 AMS 27L LAB #8 Winter 29 Solving ODE s in Matlab Objectives:. To use Matlab s ODE Solvers 2. To practice using functions and in-line functions Matlab s ODE Suite Matlab offers a suite of ODE solvers including:

More information

Matlab Section. November 8, 2005

Matlab Section. November 8, 2005 Matlab Section November 8, 2005 1 1 General commands Clear all variables from memory : clear all Close all figure windows : close all Save a variable in.mat format : save filename name of variable Load

More information

1 Overview of Simulink. 2 State-space equations

1 Overview of Simulink. 2 State-space equations Modelling and simulation of engineering systems Simulink Exercise 1 - translational mechanical systems Dr. M. Turner (mct6@sun.engg.le.ac.uk 1 Overview of Simulink Simulink is a package which runs in the

More information

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations Lecture 8: Calculus and Differential Equations Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 9. Numerical Methods MATLAB provides

More information

Lecture 8: Calculus and Differential Equations

Lecture 8: Calculus and Differential Equations Lecture 8: Calculus and Differential Equations Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE21: Computer Applications. See Textbook Chapter 9. Numerical Methods MATLAB provides

More information

Introduction to MatLab

Introduction to MatLab Introduction to MatLab 1 Introduction to MatLab Graduiertenkolleg Kognitive Neurobiologie Friday, 05 November 2004 Thuseday, 09 Novemer 2004 Kurt Bräuer Institut für Theoretische Physik, Universität Tübingen

More information

Laboratory 1. Solving differential equations with nonzero initial conditions

Laboratory 1. Solving differential equations with nonzero initial conditions Laboratory 1 Solving differential equations with nonzero initial conditions 1. Purpose of the exercise: - learning symbolic and numerical methods of differential equations solving with MATLAB - using Simulink

More information

Lesson 11: Mass-Spring, Resonance and ode45

Lesson 11: Mass-Spring, Resonance and ode45 Lesson 11: Mass-Spring, Resonance and ode45 11.1 Applied Problem. Trucks and cars have springs and shock absorbers to make a comfortable and safe ride. Without good shock absorbers, the truck or car will

More information

Solving ODEs and PDEs in MATLAB. Sören Boettcher

Solving ODEs and PDEs in MATLAB. Sören Boettcher 16.02.2009 Introduction Quick introduction to syntax ODE in the form of Initial Value Problems (IVP) what equations can handle how to code into how to choose the right solver how to get the solver to do

More information

MATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu

MATLAB BASICS. Instructor: Prof. Shahrouk Ahmadi. TA: Kartik Bulusu MATLAB BASICS Instructor: Prof. Shahrouk Ahmadi 1. What are M-files TA: Kartik Bulusu M-files are files that contain a collection of MATLAB commands or are used to define new MATLAB functions. For the

More information

Ordinary Differential Equations (ode)

Ordinary Differential Equations (ode) Ordinary Differential Equations (ode) Numerical Methods for Solving Initial condition (ic) problems and Boundary value problems (bvp) What is an ODE? =,,...,, yx, dx dx dx dx n n 1 n d y d y d y In general,

More information

L3: Review of linear algebra and MATLAB

L3: Review of linear algebra and MATLAB L3: Review of linear algebra and MATLAB Vector and matrix notation Vectors Matrices Vector spaces Linear transformations Eigenvalues and eigenvectors MATLAB primer CSCE 666 Pattern Analysis Ricardo Gutierrez-Osuna

More information

EEE161 Applied Electromagnetics Laboratory 1

EEE161 Applied Electromagnetics Laboratory 1 Dr. Milica Marković Applied Electromagnetics Laboratory page 1 EEE161 Applied Electromagnetics Laboratory 1 Instructor: Dr. Milica Marković Office: Riverside Hall 3028 Email: milica@csus.edu Web:http://gaia.ecs.csus.edu/

More information

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB, Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB, Part I: Basics MATLAB Environment Getting Help Variables Vectors, Matrices, and

More information

Ordinary Differential Equations (ODE)

Ordinary Differential Equations (ODE) Ordinary Differential Equations (ODE) Why study Differential Equations? Many physical phenomena are best formulated mathematically in terms of their rate of change. Motion of a swinging pendulum Bungee-jumper

More information

Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave

Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave Vector Fields and Solutions to Ordinary Differential Equations using MATLAB/Octave Andreas Stahel 5th December 27 Contents Vector field for the logistic equation 2 Solutions of ordinary differential equations

More information

13 Numerical Solution of ODE s

13 Numerical Solution of ODE s 13 NUMERICAL SOLUTION OF ODE S 28 13 Numerical Solution of ODE s In simulating dynamical systems, we frequently solve ordinary differential equations. These are of the form dx = f(t, x), dt where the function

More information

MAT 275 Laboratory 7 Laplace Transform and the Symbolic Math Toolbox

MAT 275 Laboratory 7 Laplace Transform and the Symbolic Math Toolbox Laplace Transform and the Symbolic Math Toolbox 1 MAT 275 Laboratory 7 Laplace Transform and the Symbolic Math Toolbox In this laboratory session we will learn how to 1. Use the Symbolic Math Toolbox 2.

More information

We begin exploring Euler s method by looking at direction fields. Consider the direction field below.

We begin exploring Euler s method by looking at direction fields. Consider the direction field below. Emma Reid- MA 66, Lesson 9 (SU 17) Euler s Method (.7) So far in this course, we have seen some very special types of first order ODEs. We ve seen methods to solve linear, separable, homogeneous, Bernoulli,

More information

Lecture 5b: Starting Matlab

Lecture 5b: Starting Matlab Lecture 5b: Starting Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University August 7, 2013 Outline 1 Resources 2 Starting Matlab 3 Homework

More information

Lecture 2. Introduction to Differential Equations. Roman Kitsela. October 1, Roman Kitsela Lecture 2 October 1, / 25

Lecture 2. Introduction to Differential Equations. Roman Kitsela. October 1, Roman Kitsela Lecture 2 October 1, / 25 Lecture 2 Introduction to Differential Equations Roman Kitsela October 1, 2018 Roman Kitsela Lecture 2 October 1, 2018 1 / 25 Quick announcements URL for the class website: http://www.math.ucsd.edu/~rkitsela/20d/

More information

Solving systems of ODEs with Matlab

Solving systems of ODEs with Matlab Solving systems of ODEs with Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 20, 2013 Outline 1 Systems of ODEs 2 Setting Up

More information

Mon Jan Improved acceleration models: linear and quadratic drag forces. Announcements: Warm-up Exercise:

Mon Jan Improved acceleration models: linear and quadratic drag forces. Announcements: Warm-up Exercise: Math 2250-004 Week 4 notes We will not necessarily finish the material from a given day's notes on that day. We may also add or subtract some material as the week progresses, but these notes represent

More information

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB

(Linear equations) Applied Linear Algebra in Geoscience Using MATLAB Applied Linear Algebra in Geoscience Using MATLAB (Linear equations) Contents Getting Started Creating Arrays Mathematical Operations with Arrays Using Script Files and Managing Data Two-Dimensional Plots

More information

Read through A Graphing Checklist for Physics Graduate Students before submitting any plots in this module. See the course website for the link.

Read through A Graphing Checklist for Physics Graduate Students before submitting any plots in this module. See the course website for the link. Module C2: MatLab The Physics and Astronomy Department has several copies of MATLAB installed on computers that can be accessed by students. MATLAB is a highly developed software package that allows the

More information

An Introduction to MatLab

An Introduction to MatLab Introduction to MatLab 1 An Introduction to MatLab Contents 1. Starting MatLab... 3 2. Workspace and m-files... 4 3. Help... 5 4. Vectors and Matrices... 5 5. Objects... 8 6. Plots... 10 7. Statistics...

More information

Numerical Methods with Matlab: Implementations and Applications. Gerald W. Recktenwald

Numerical Methods with Matlab: Implementations and Applications. Gerald W. Recktenwald Selected Solutions for Exercises in Numerical Methods with Matlab: Implementations and Applications Gerald W. Recktenwald Chapter 12 Numerical Integration of Ordinary Differential Equations The following

More information

A First Course on Kinetics and Reaction Engineering Example S5.1

A First Course on Kinetics and Reaction Engineering Example S5.1 Example S5.1 Problem Purpose This example illustrates the use of the MATLAB template file SolvBVDif.m to solve a second order boundary value ordinary differential equation. Problem Statement Solve the

More information

Review for Exam 2 Ben Wang and Mark Styczynski

Review for Exam 2 Ben Wang and Mark Styczynski Review for Exam Ben Wang and Mark Styczynski This is a rough approximation of what we went over in the review session. This is actually more detailed in portions than what we went over. Also, please note

More information

Integration by Parts Logarithms and More Riemann Sums!

Integration by Parts Logarithms and More Riemann Sums! Integration by Parts Logarithms and More Riemann Sums! James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University September 16, 2013 Outline 1 IbyP with

More information

A Glimpse at Scipy FOSSEE. June Abstract This document shows a glimpse of the features of Scipy that will be explored during this course.

A Glimpse at Scipy FOSSEE. June Abstract This document shows a glimpse of the features of Scipy that will be explored during this course. A Glimpse at Scipy FOSSEE June 010 Abstract This document shows a glimpse of the features of Scipy that will be explored during this course. 1 Introduction SciPy is open-source software for mathematics,

More information

The roots are found with the following two statements. We have denoted the polynomial as p1, and the roots as roots_ p1.

The roots are found with the following two statements. We have denoted the polynomial as p1, and the roots as roots_ p1. Part II Lesson 10 Numerical Analysis Finding roots of a polynomial In MATLAB, a polynomial is expressed as a row vector of the form [an an 1 a2 a1 a0]. The elements ai of this vector are the coefficients

More information

CONTROL SYSTEMS LABORATORY ECE311 LAB 1: The Magnetic Ball Suspension System: Modelling and Simulation Using Matlab

CONTROL SYSTEMS LABORATORY ECE311 LAB 1: The Magnetic Ball Suspension System: Modelling and Simulation Using Matlab CONTROL SYSTEMS LABORATORY ECE311 LAB 1: The Magnetic Ball Suspension System: Modelling and Simulation Using Matlab 1 Introduction and Purpose The purpose of this experiment is to familiarize you with

More information

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 103L Fall Test 2 Solutions. Michael R. Gustafson II

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 103L Fall Test 2 Solutions. Michael R. Gustafson II 'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ EGR 103L Fall 2017 Test 2 Solutions Michael R. Gustafson II Name (please print) NET ID (please print): In keeping with the Community Standard, I have neither

More information

Statistical methods. Mean value and standard deviations Standard statistical distributions Linear systems Matrix algebra

Statistical methods. Mean value and standard deviations Standard statistical distributions Linear systems Matrix algebra Statistical methods Mean value and standard deviations Standard statistical distributions Linear systems Matrix algebra Statistical methods Generating random numbers MATLAB has many built-in functions

More information

AMS 27L LAB #6 Winter 2009

AMS 27L LAB #6 Winter 2009 AMS 27L LAB #6 Winter 2009 Symbolically Solving Differential Equations Objectives: 1. To learn about the MATLAB Symbolic Solver 2. To expand knowledge of solutions to Diff-EQs 1 Symbolically Solving Differential

More information

ENED 1091 HW#3 Due Week of February 22 nd

ENED 1091 HW#3 Due Week of February 22 nd ENED 1091 HW#3 Due Week of February 22 nd Problem 1: The graph below shows position measurements (in cm) collected every 0.5 seconds over a 10 second interval of time. (a) Using linear interpolation, estimate

More information

. var save filename var. y fprintf(fl,'%f %f\n',y) y ..TXT. . fprintf() .TXT. myf = fopen('nam.txt','w'); nam.txt myf.

. var save filename var. y fprintf(fl,'%f %f\n',y) y ..TXT. . fprintf() .TXT. myf = fopen('nam.txt','w'); nam.txt myf. y fprintf(fl,'%f %f\n',y) y. \n.txt. fprintf()..txt.. myf = fopen('nam.txt','w'); :. (1-4 )..TXT. % Optt.m av =[17.4537 4.57 15.3 17.869 3.7]; Tit = 'Students Average:'; myf = fopen('nam.txt','w'); fprintf(myf,'%s\n',tit);

More information

Solution. Your sketch should show both x and y axes marked from 5 to 5 and circles of radius 1, 3, and 5 centered at the origin.

Solution. Your sketch should show both x and y axes marked from 5 to 5 and circles of radius 1, 3, and 5 centered at the origin. Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 208, Professor David Levermore () (a) Sketch the graph that would be produced by the following Matlab command. fplot(@(t) 2/t,

More information

Physics 241 Class #10 Outline (9/25/2013) Plotting Handle graphics Numerical derivatives and functions Next time numerical integrals

Physics 241 Class #10 Outline (9/25/2013) Plotting Handle graphics Numerical derivatives and functions Next time numerical integrals Physics 241 Class #10 Outline (9/25/2013) Plotting Handle graphics Numerical derivatives and functions Next time numerical integrals Announcements HW4 grades are up. HW5a HW5 revised Same problems, now

More information

Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 2017, Professor David Levermore

Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 2017, Professor David Levermore Solutions of the Sample Problems for the First In-Class Exam Math 246, Fall 207, Professor David Levermore () (a) Give the integral being evaluated by the following Matlab command. int( x/(+xˆ4), x,0,inf)

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Macroeconomics Vivaldo Mendes Dep. Economics Instituto Universitário de Lisboa September 2017 (Vivaldo Mendes ISCTE-IUL ) Macroeconomics September 2013 1 / 41 Summary 1 Introduction

More information

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 103L Fall Test 2. Michael R. Gustafson II

'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ. EGR 103L Fall Test 2. Michael R. Gustafson II 'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ EGR 103L Fall 2017 Test 2 Michael R. Gustafson II Name (please print) NET ID (please print): In keeping with the Community Standard, I have neither provided

More information

USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS

USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS USE OF MATLAB TO UNDERSTAND BASIC MATHEMATICS Sanjay Gupta P. G. Department of Mathematics, Dev Samaj College For Women, Punjab ( India ) ABSTRACT In this paper, we talk about the ways in which computer

More information

New Mexico Tech Hyd 510

New Mexico Tech Hyd 510 Vectors vector - has magnitude and direction (e.g. velocity, specific discharge, hydraulic gradient) scalar - has magnitude only (e.g. porosity, specific yield, storage coefficient) unit vector - a unit

More information

HW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Prog

HW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Prog HW5 computer problem: modelling a dye molecule Objectives By the end of this lab you should: Know how to manipulate complex numbers and matrices. Programming environment: Spyder. To implement this, do

More information

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of

Scientific Computing with Case Studies SIAM Press, Lecture Notes for Unit V Solution of Scientific Computing with Case Studies SIAM Press, 2009 http://www.cs.umd.edu/users/oleary/sccswebpage Lecture Notes for Unit V Solution of Differential Equations Part 1 Dianne P. O Leary c 2008 1 The

More information

Solving systems of first order equations with ode Systems of first order differential equations.

Solving systems of first order equations with ode Systems of first order differential equations. A M S 20 MA TLA B NO T E S U C S C Solving systems of first order equations with ode45 c 2015, Yonatan Katznelson The M A T L A B numerical solver, ode45 is designed to work with first order differential

More information

SYMBOLIC AND NUMERICAL COMPUTING FOR CHEMICAL KINETIC REACTION SCHEMES

SYMBOLIC AND NUMERICAL COMPUTING FOR CHEMICAL KINETIC REACTION SCHEMES SYMBOLIC AND NUMERICAL COMPUTING FOR CHEMICAL KINETIC REACTION SCHEMES by Mark H. Holmes Yuklun Au J. W. Stayman Department of Mathematical Sciences Rensselaer Polytechnic Institute, Troy, NY, 12180 Abstract

More information

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0

Solution: (a) Before opening the parachute, the differential equation is given by: dv dt. = v. v(0) = 0 Math 2250 Lab 4 Name/Unid: 1. (35 points) Leslie Leroy Irvin bails out of an airplane at the altitude of 16,000 ft, falls freely for 20 s, then opens his parachute. Assuming linear air resistance ρv ft/s

More information

First In-Class Exam Solutions Math 246, Professor David Levermore Thursday, 20 September 2018

First In-Class Exam Solutions Math 246, Professor David Levermore Thursday, 20 September 2018 First In-Class Exam Solutions Math 246, Professor David Levermore Thursday, 20 September 208 () [6] In the absence of predators the population of mosquitoes in a certain area would increase at a rate proportional

More information

Experiment 1: Linear Regression

Experiment 1: Linear Regression Experiment 1: Linear Regression August 27, 2018 1 Description This first exercise will give you practice with linear regression. These exercises have been extensively tested with Matlab, but they should

More information

Initial value problems for ordinary differential equations

Initial value problems for ordinary differential equations AMSC/CMSC 660 Scientific Computing I Fall 2008 UNIT 5: Numerical Solution of Ordinary Differential Equations Part 1 Dianne P. O Leary c 2008 The Plan Initial value problems (ivps) for ordinary differential

More information

Math 515 Fall, 2008 Homework 2, due Friday, September 26.

Math 515 Fall, 2008 Homework 2, due Friday, September 26. Math 515 Fall, 2008 Homework 2, due Friday, September 26 In this assignment you will write efficient MATLAB codes to solve least squares problems involving block structured matrices known as Kronecker

More information

MAE143A Signals & Systems - Homework 5, Winter 2013 due by the end of class Tuesday February 12, 2013.

MAE143A Signals & Systems - Homework 5, Winter 2013 due by the end of class Tuesday February 12, 2013. MAE43A Signals & Systems - Homework 5, Winter 23 due by the end of class Tuesday February 2, 23. If left under my door, then straight to the recycling bin with it. This week s homework will be a refresher

More information

ENGR Spring Exam 2

ENGR Spring Exam 2 ENGR 1300 Spring 013 Exam INSTRUCTIONS: Duration: 60 minutes Keep your eyes on your own work! Keep your work covered at all times! 1. Each student is responsible for following directions. Read carefully..

More information

Table 1 Principle Matlab operators and functions Name Description Page reference

Table 1 Principle Matlab operators and functions Name Description Page reference Matlab Index Table 1 summarises the Matlab supplied operators and functions to which we have referred. In most cases only a few of the options available to the individual functions have been fully utilised.

More information

Chapter 1: Introduction

Chapter 1: Introduction Chapter 1: Introduction Definition: A differential equation is an equation involving the derivative of a function. If the function depends on a single variable, then only ordinary derivatives appear and

More information

Vector Fields and Solutions to Ordinary Differential Equations using Octave

Vector Fields and Solutions to Ordinary Differential Equations using Octave Vector Fields and Solutions to Ordinary Differential Equations using Andreas Stahel 6th December 29 Contents Vector fields. Vector field for the logistic equation...............................2 Solutions

More information

TUTORIAL: STATE VARIABLES and MATLAB

TUTORIAL: STATE VARIABLES and MATLAB TUTORIAL TUTORIAL: STATE VARIABLES and MATLAB Time-domain analysis of circuits with more than one L and C is difficult because it requires solution of characteristic equations higher than second degree.

More information

A First Course on Kinetics and Reaction Engineering Example 30.1

A First Course on Kinetics and Reaction Engineering Example 30.1 Example 30.1 Problem Purpose This problem will help you determine whether you have mastered the learning objectives for this unit. It illustrates the general approach to solving the design equations for

More information

Quantitative Understanding in Biology Module IV: ODEs Lecture I: Introduction to ODEs

Quantitative Understanding in Biology Module IV: ODEs Lecture I: Introduction to ODEs Quantitative Understanding in Biology Module IV: ODEs Lecture I: Introduction to ODEs Ordinary Differential Equations We began our exploration of dynamic systems with a look at linear difference equations.

More information

MAT 275 Laboratory 6 Forced Equations and Resonance

MAT 275 Laboratory 6 Forced Equations and Resonance MAT 275 Laboratory 6 Forced Equations and Resonance In this laboratory we take a deeper look at second-order nonhomogeneous equations. We will concentrate on equations with a periodic harmonic forcing

More information

Introduction to SVD and Applications

Introduction to SVD and Applications Introduction to SVD and Applications Eric Kostelich and Dave Kuhl MSRI Climate Change Summer School July 18, 2008 Introduction The goal of this exercise is to familiarize you with the basics of the singular

More information

Computer Labs for. Differential Equations & Linear Algebra

Computer Labs for. Differential Equations & Linear Algebra Computer Labs for Differential Equations & Linear Algebra Contents Preface............................... i Lab 1: Slope Fields and Solution Curves................. 1 Lab 2: Numerical Methods of Euler...................

More information

Laboratory 10 Forced Equations and Resonance

Laboratory 10 Forced Equations and Resonance MATLAB sessions: Laboratory 9 Laboratory Forced Equations and Resonance ( 3.6 of the Edwards/Penney text) In this laboratory we take a deeper look at second-order nonhomogeneous equations. We will concentrate

More information

Lesson 9: Predator-Prey and ode45

Lesson 9: Predator-Prey and ode45 Lesson 9: Predator-Prey and ode45 9.1 Applied Problem. In this lesson we will allow for more than one population where they depend on each other. One population could be the predator such as a fox, and

More information

AMATH 301 Beginning Scientific Computing

AMATH 301 Beginning Scientific Computing AMATH 301 Beginning Scientific Computing J. Nathan Kutz January 5, 2005 Abstract This course is a survey of basic numerical methods and algorithms used for linear algebra, ordinary and partial differential

More information

MATH 373 Numerical Analysis Homework #1 Assigned: January 24, 2018 Due: February 2, 2018

MATH 373 Numerical Analysis Homework #1 Assigned: January 24, 2018 Due: February 2, 2018 MATH 373 Numerical Analysis Homework #1 Assigned: January 24, 2018 Due: February 2, 2018 1. Develop an M-file for the Bisection Method. Command-line usage is [root,func val,error approx,num iterations]

More information

Spis treści Contents List of Examples Preface to Third Edition 21

Spis treści Contents List of Examples Preface to Third Edition 21 An engineer's guide to MATLAB : with applications from mechanical, aerospace, electrical, civil, and biological systems engineering / Edward B. Magrab [et al.]. - 3rd ed. - Boston, cop. 2011 Spis treści

More information

2D Plotting with Matlab

2D Plotting with Matlab GEEN 1300 Introduction to Engineering Computing Class Meeting #22 Monday, Nov. 9 th Engineering Computing and Problem Solving with Matlab 2-D plotting with Matlab Script files User-defined functions Matlab

More information

Project Two. James K. Peterson. March 26, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Project Two. James K. Peterson. March 26, Department of Biological Sciences and Department of Mathematical Sciences Clemson University Project Two James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University March 26, 2019 Outline 1 Cooling Models 2 Estimating the Cooling Rate k 3 Typical

More information

1 Introduction to MATLAB

1 Introduction to MATLAB L3 - December 015 Solving PDEs numerically (Reports due Thursday Dec 3rd, carolinemuller13@gmail.com) In this project, we will see various methods for solving Partial Differential Equations (PDEs) using

More information

Section 7.4 Runge-Kutta Methods

Section 7.4 Runge-Kutta Methods Section 7.4 Runge-Kutta Methods Key terms: Taylor methods Taylor series Runge-Kutta; methods linear combinations of function values at intermediate points Alternatives to second order Taylor methods Fourth

More information

Matlab for Review. NDSU Matlab Review pg 1

Matlab for Review. NDSU Matlab Review pg 1 NDSU Matlab Review pg 1 Becoming familiar with MATLAB The console The editor The graphics windows The help menu Saving your data (diary) General environment and the console Matlab for Review Simple numerical

More information

LAB 1: MATLAB - Introduction to Programming. Objective:

LAB 1: MATLAB - Introduction to Programming. Objective: LAB 1: MATLAB - Introduction to Programming Objective: The objective of this laboratory is to review how to use MATLAB as a programming tool and to review a classic analytical solution to a steady-state

More information

Solving Linear Systems of ODEs with Matlab

Solving Linear Systems of ODEs with Matlab Solving Linear Systems of ODEs with Matlab James K. Peterson Department of Biological Sciences and Department of Mathematical Sciences Clemson University October 27, 2013 Outline Linear Systems Numerically

More information

MATLAB for Engineers

MATLAB for Engineers MATLAB for Engineers Adrian Biran Moshe Breiner ADDISON-WESLEY PUBLISHING COMPANY Wokingham, England Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Amsterdam Bonn Sydney Singapore

More information

Numerical solution of ODEs

Numerical solution of ODEs Péter Nagy, Csaba Hős 2015. H-1111, Budapest, Műegyetem rkp. 3. D building. 3 rd floor Tel: 00 36 1 463 16 80 Fax: 00 36 1 463 30 91 www.hds.bme.hu Table of contents Homework Introduction to Matlab programming

More information

Solving Differential Equations Using MATLAB

Solving Differential Equations Using MATLAB Solving Differential Equations Using MATLAB Abraham Asfaw aasfaw.student@manhattan.edu November 28, 2011 1 Introduction In this lecture, we will follow up on lecture 2 with a discussion of solutions to

More information

Lab 2: Static Response, Cantilevered Beam

Lab 2: Static Response, Cantilevered Beam Contents 1 Lab 2: Static Response, Cantilevered Beam 3 1.1 Objectives.......................................... 3 1.2 Scalars, Vectors and Matrices (Allen Downey)...................... 3 1.2.1 Attribution.....................................

More information

Is the World Going to End in 2029?

Is the World Going to End in 2029? Is the World Going to End in 9? No, but why do you ask? Asteroid (MN ) a.k.a. is a near-earth asteroid discovered in. Preliminary orbital calculations indicated that in would slam into on April 3, 9. Since

More information

2 Solving Ordinary Differential Equations Using MATLAB

2 Solving Ordinary Differential Equations Using MATLAB Penn State Erie, The Behrend College School of Engineering E E 383 Signals and Control Lab Spring 2008 Lab 3 System Responses January 31, 2008 Due: February 7, 2008 Number of Lab Periods: 1 1 Objective

More information

ES.1803 Topic 13 Notes Jeremy Orloff

ES.1803 Topic 13 Notes Jeremy Orloff ES.1803 Topic 13 Notes Jeremy Orloff 13 Vector Spaces, matrices and linearity 13.1 Goals 1. Know the definition of a vector space and how to show that a given set is a vector space. 2. Know the meaning

More information

Using Matlab to integrate Ordinary Differential Equations (ODEs)

Using Matlab to integrate Ordinary Differential Equations (ODEs) Using Matlab to integrate Ordinary Differential Equations (ODEs) Erica McEvoy (Dated: June 17, 2009) 1. INTRODUCTION Ordinary differential equations tend to arise whenever you need to model changing quantities

More information

Announcements Monday, September 18

Announcements Monday, September 18 Announcements Monday, September 18 WeBWorK 1.4, 1.5 are due on Wednesday at 11:59pm. The first midterm is on this Friday, September 22. Midterms happen during recitation. The exam covers through 1.5. About

More information

Chart 3 Data in Array

Chart 3 Data in Array Chart 3 Data in Array 3.1. How to Handle Data in Table Form 3.1.1 Create Matrix and Tables 1. Choose an input mode cell where you like to create a table. Next, choose Insert (I) - Table & Matrix (M) -

More information

How to Create Matlab Script and Simulink Model for Designing a Pole Placement Controller

How to Create Matlab Script and Simulink Model for Designing a Pole Placement Controller How to Create Matlab Script and Simulink Model for Designing a Pole Placement Controller 1(37) Pole Placement Controller Design H tot Y ( z) Kr B ( z) R( z) A( z) C( z) B( z) D( z) P( z) A( z) C( z) B(

More information

2007 Summer College on Plasma Physics

2007 Summer College on Plasma Physics 856-7 Summer College on Plasma Physics July - 4 August, 7 Numerical methods and simulations. Lecture : Simulation of partial differential equations. B. Eliasson Institut Fuer Theoretische Physik IV Ruhr-Universitaet

More information

Quantitative Understanding in Biology Module IV: ODEs Lecture I: Introduction to ODEs

Quantitative Understanding in Biology Module IV: ODEs Lecture I: Introduction to ODEs Quantitative Understanding in Biology Module IV: ODEs Lecture I: Introduction to ODEs Ordinary Differential Equations We began our exploration of dynamic systems with a look at linear difference equations.

More information

Introduction to First Order Equations Sections

Introduction to First Order Equations Sections A B I L E N E C H R I S T I A N U N I V E R S I T Y Department of Mathematics Introduction to First Order Equations Sections 2.1-2.3 Dr. John Ehrke Department of Mathematics Fall 2012 Course Goals The

More information

WILEY. Differential Equations with MATLAB (Third Edition) Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg

WILEY. Differential Equations with MATLAB (Third Edition) Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg Differential Equations with MATLAB (Third Edition) Updated for MATLAB 2011b (7.13), Simulink 7.8, and Symbolic Math Toolbox 5.7 Brian R. Hunt Ronald L. Lipsman John E. Osborn Jonathan M. Rosenberg All

More information

Homework 1 Solutions

Homework 1 Solutions 18-9 Signals and Systems Profs. Byron Yu and Pulkit Grover Fall 18 Homework 1 Solutions Part One 1. (8 points) Consider the DT signal given by the algorithm: x[] = 1 x[1] = x[n] = x[n 1] x[n ] (a) Plot

More information

ECE 3793 Matlab Project 3

ECE 3793 Matlab Project 3 ECE 3793 Matlab Project 3 Spring 2017 Dr. Havlicek DUE: 04/25/2017, 11:59 PM What to Turn In: Make one file that contains your solution for this assignment. It can be an MS WORD file or a PDF file. Make

More information