Solve the ODE
Use the Euler forward method (forward differencing)
Consider the following values of β
B = 0
B = -0.199
B = 0.8
Discretization
Solve it on the interval:
0 <= n <= 10 with n_n = 1000 points
discretize eta
define start value of eta: eta_s
define end value of eta: eta_e
define number of points: n_eta
discretize eta
preallocate arrays to store solution
store solution for beta = 0 case in yb1
store solution for beta = -0.199 case in yb2
store solution for beta = 0.8 case in yb3
NOTE: each solution vector needs to hold n_eta rows and 3 columns
where n_eta is the number of points used to discretize eta
define ode function to update solution
define an anonymous function (function handle) with thefollowing properties
name: dydeta
inputs: y and beta, where y is a row vector with 3 values and beta is a scalar
ouptuts: a row vector with the rate of change of the state defined with the reduced order system above
ode check
define a row vector names y_check with the values: 1, 2 and 3
assign a variable named beta_check the value -1
call the previously define function dydeta with the inputs y_check and beta_check and store the result in dy_check
solve the ode for case 1 (beta = 0)
assign beta value
apply initial condition provided for beta = 0
solve the ode using forward differencing
solve the ode for case 2 (beta = -0.199)
assign beta value
set initial condition for beta = -0.199
solve the ode using forward differencing
solve ode for case 3 (beta = 0.8)
assign beta value
set initial condition for beta = 0.8
solve the ode using forward differencing
plot results
plot the second column of yb1 over eta as a blue line with line width 4
in the same plot add:
the second column of yb2 over eta as a red line with line width 4
the second column of yb2 over eta as a green line with line width 4
customize the plot
- switch on the grid
- set font size to 20
Reduced order system:
y`1 = y2
y`2 = y3
y`3 = -y1(y3)-B[1-(y2)^2]
Initial conditions:
B = 0 case:
y1(n=0) = 0
y2(n=0) = 0
y3(n=0) = 0.4696
B = -0.199 case:
y1(n=0) = 0
y2(n=0) = 0
y3(n=0) = -0.0008
B = 0.8 case:
y1(n=0) = 0
y2(n=0) = 0
y3(n=0) = 1.1172
MATLAB code