This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: cos ( t /10)-x end Listing 4: fun4.m % Steady state % beta ( t ) = 1 function xprime = fun4 ( t , x) xprime = 1-x end Next, we set up the range over which the simulation is done (0 to 200 π at intervals of π/ 4), and deﬁne the initial value of X * as zero. Listing 5: Range and initial value tspan = [ 0 : pi /4:200 * pi ] x0 = 0 Finally, we invoke the ODE solver ode45 built into Matlab, and plot the results. Listing 6: Solve and plot [ t1 , x1 ] = ode45 (@fun1 , tspan , x0 ) ; [ t2 , x2 ] = ode45 (@fun2 , tspan , x0 ) ; [ t3 , x3 ] = ode45 (@fun3 , tspan , x0 ) ; [ t4 , x4 ] = ode45 (@fun4 , tspan , x0 ) ; plot ( t1 , x1 , ’ r-’ , t2 , x2 , ’g-’ , t3 , x3 , ’b-’ , t4 , x4 , ’--’ ) ; The plot should look like the one below. The red line is for fast switching, green for matched, blue for slow, and dotted for the steady state case. 2 3...
View Full Document
- Fall '09
- initial value, ODE solver, function xprime, Rahul Karnik