You are on page 1of 3

# MEEN

357

## Engineering Analysis for Mechanical Engineers

Assignment 6: Numerical Integration + ODE

Fall 2012

Assigned: Due Date: Due Time: October 16 October 24 12 PM CST (hard copy) 5 PM CST Submission: Electronic/Hardcopy Collaboration Type: Individual Grading: 30 pts

10/16/12

MEEN 357

## Engineering Analysis for Mechanical Engineers

Fall 2012

Task 2: Euler Method (5 pts) Write a program to implement Eulers Method. [t,y] = a06_ode_Euler(diffeq,tspan, y0, ssize) % diffeq = (string) name of the m-file that evaluates the right hand side of the ODE written in standard form % tspan = Time span [t0,tf] % y0 = initial condition for the dependent variable % ssize = stepsize for advancing the independent variable % Output: % t = vector of independent variable values: t(j)=(j-1)*h % y = vector of numerical solution values at the t(j) THIS CODE SHOULD BE ABLE TO HANDLE SYSTEMS OF ODEs AS WELL Specifications: Function should check that tspan is a 1-D array Function should check that ssize is a scalar Function should check that y0 is a scalar OR a 1-D array Deliverables: Matlab file a06_ode_Euler.m Program Listing (Hard Copy) Task 3: Runge-Kutta, fourth order (5 pts) Write a program to implement Runge-Kuta 4th Order Method. [t,y] = a06_ode_RK4(diffeq,tspan,y0,ssize) % diffeq = (string) name of the m-file that evaluates the right hand side of the ODE written in standard form % tspan = Time span [t0,tf] % y0 = initial condition for the dependent variable % ssize = stepsize for advancing the independent variable % Output: % t = vector of independent variable values: t(j)=(j-1)*h % y = vector of numerical solution values at the t(j) THIS CODE SHOULD BE ABLE TO HANDLE SYSTEMS OF ODEs AS WELL Specifications: Function should check that tspan is a 1-D array Function should check that ssize is a scalar Function should check that y0 is a scalar OR a 1-D array Deliverables: Matlab file a06_ode_RK4.m Program Listing (Hard Copy)

10/16/12

MEEN 357

## Engineering Analysis for Mechanical Engineers

Fall 2012

Task 4: Solution to Text Problem (5 pts) Create a script named a06_25_4.m that solves the differential equation in problem 25.4. You should also provide with the function a06_function_25_4.m that implements the differential equation. Your code should call your a06_ode_RK4 code. No MATLAB ODE solver allowed. The script should output a properly formatted figure of the behavior of y(1) and y(2) vs t. Deliverables: Matlab file a06_25_4.m and a06_function_25_4.m Program Listing (Hard Copy) Task 5: Solution to Text Problem (5 pts) Create a script named a06_25_20.m that solves the differential equation in problem 25.20. You should also provide with the function a06_function_25_20.m that implements the differential equation(s). You may use any MATLAB ODE solver you want. The script should display a properly formatted solution (i. e. The time to empty the tank is xx seconds.) The script should also plot the height of water in the tank as a function of time. Use proper labels and legends. Deliverables: Matlab file a06_25_20.m and a06_function_25_20.m Program Listing (Hard Copy) Task 5: Hard Copy Problems (6 points) Problem 25.1 Problem 25.4 Problem 25.7

10/16/12