Solve a differential equation analytically by using the dsolve function, with or without initial conditions. This MATLAB function solves the differential equation eqn, where eqn is a symbolic Alternatively, you can directly assign solutions to functions or variables by. When working with differential equations, MATLAB provides two different approaches: numerical and symbolic. Here, you can see both approaches to solving.
differential equations symbolically.1 Suppose, for example, that we want to solve 1Actually, whenever you do symbolic manipulations in MATLAB what you're. Other MATLAB differential equation solvers. Using MATLAB solvers and optimizers to make design decisions. Using fzero to solve equations. First, you have to reduce the order. Let z = y' => z' = y". Your ODE then becomes z ' = sqrt(-2*z - 3*y + sin(x)), with z(0) = 0 y' = z, with y(0) = 1. You can now write.
We have to define a MATLAB function equal to the right side of the equation, which we can do with an anonymous function. syms t f = @(t,y) 2.*y -1 f = @(t,y)2.