This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Math245 Computer Lab set #10, Fall 2008 Response to step input In this lab, we will simulate the 2nd order ODE with discontinuous forcing function. To start with, we define the step function in Matlab. Then we will simulate an example problem by using the step function for the forcing function. The step function As we learned in the class, the step function u ( t ) is defined u ( t ) = ( t < 1 t (1) The shifted step function u ( t- c ) is expressed u ( t- c ) = ( t- c < 0 ( t < c ) 1 t- c 0 ( t c ) (2) 1 t u(t-c) c 1 t u(t) Design step function in Matlab To define the step function u ( t ), we create a Matlab function file ( step.m ) as follows. function y = step(t) if t < 0 y = 0; else y = 1; end There are two points to make: Matlab function The Matlab function is a independent program unit that has a certain function. The simplest form of the function is written function out = fun_name(in1, in2,...) out = some expression using in1, in2, etc. This function is has its name fun name . And this file should be saved as fun name.m . in1, in2,... are called input arguments, and...
View Full Document