For this task you have two options Option 1 Generate the ma

For this task, you have two options: Option 1: (**) Generate the matrix A as displayed using a \'for\' loop, and use built-in MATLAB functions such as backslash operator or inv (A) to solve the system.

Solution

A typical approach to solving higher-order ordinary differential equations is to convert them to systems of first-order differential equations, and then solve those systems.

Rewrite the Second-Order ODE as a System of First-Order ODEs

Use odeToVectorField to rewrite this second-order differential equation as a system of first-order differential equations.

Generate MATLAB function

The MATLAB ODE solvers do not accept symbolic expressions as an input. therefore, before you can use a MATLAB ODE solver to solve the system, you must convert that system to a MATLAB function. Generate a MATLAB function from this system of first-order differential equations using matlabFunction with V as an input.

Solve the System of First-Order ODEs

To solve this system, call the MATLAB ode45 numerical solver using the generated MATLAB function as an input.

Plot the Solution

Plot the solution using linspace to generate 100 points in the interval [0,20] and deval to evaluate the solution for each point.

>>eqn2 = ’D2y + 8*Dy + 2*y = cos(x)’;

>>inits2 = ’y(0)=0, Dy(0)=1’;

>>y=dsolve(eqn2,inits2,’x’)

y =

1/65*cos(x)+8/65*sin(x)+(-1/130+53/1820*14ˆ(1/2))*exp((-4+14ˆ(1/2))*x) -1/1820*(53+14ˆ(1/2))*14ˆ(1/2)*exp(-(4+14ˆ(1/2))*x)

>>z = eval(vectorize(y));

>>plot(x,z)

 For this task, you have two options: Option 1: (**) Generate the matrix A as displayed using a \'for\' loop, and use built-in MATLAB functions such as backslas

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site