forward Euler function to solve ODEs
according to the assignment I’m working on, i have to
(a) Set (tstart, tfinal, y0, f, nsteps) to be the inputs and an output vector yvec. i. tstart is the starting time ii. tfinal is the final time. iii. f is an anonymous function handle that defines the right hand side of whatever ODE we’re studying. iv. y0 is the initial condition for the given ODE v. nsteps is the number of timesteps you’re taking. vi. name the function forward_euler
(b) Define a stepsize dt using tstart, tfinal and nsteps. Then use these to construct a discretized time domain vector tvec.
(c) Set t(1) = tstart and y(1) = y0.
(d) Construct a for-loop that performs the Forward Euler algorithm that was discussed in class.
(e) (Optional but super helpful for plotting): Instead of returning only yvec, you could return [tvec, yvec]Question 2.1according to the assignment I’m working on, i have to
(a) Set (tstart, tfinal, y0, f, nsteps) to be the inputs and an output vector yvec. i. tstart is the starting time ii. tfinal is the final time. iii. f is an anonymous function handle that defines the right hand side of whatever ODE we’re studying. iv. y0 is the initial condition for the given ODE v. nsteps is the number of timesteps you’re taking. vi. name the function forward_euler
(b) Define a stepsize dt using tstart, tfinal and nsteps. Then use these to construct a discretized time domain vector tvec.
(c) Set t(1) = tstart and y(1) = y0.
(d) Construct a for-loop that performs the Forward Euler algorithm that was discussed in class.
(e) (Optional but super helpful for plotting): Instead of returning only yvec, you could return [tvec, yvec]Question 2.1 according to the assignment I’m working on, i have to
(a) Set (tstart, tfinal, y0, f, nsteps) to be the inputs and an output vector yvec. i. tstart is the starting time ii. tfinal is the final time. iii. f is an anonymous function handle that defines the right hand side of whatever ODE we’re studying. iv. y0 is the initial condition for the given ODE v. nsteps is the number of timesteps you’re taking. vi. name the function forward_euler
(b) Define a stepsize dt using tstart, tfinal and nsteps. Then use these to construct a discretized time domain vector tvec.
(c) Set t(1) = tstart and y(1) = y0.
(d) Construct a for-loop that performs the Forward Euler algorithm that was discussed in class.
(e) (Optional but super helpful for plotting): Instead of returning only yvec, you could return [tvec, yvec]Question 2.1 for loop, function, vectors MATLAB Answers — New Questions