dsolve is the command function for solving differential equations. The format for inputting the program in the Matlab command window is:
s=dsolve(‘equation1’, ‘equation2’, …, ‘initial_condition1’, ‘initial_condition2’, …, ‘independent_variable’)
Using string equations, the default value for the independent variable is t, derivatives are represented by D, second derivatives by D2, and so on. s represents the returned analytical solution.
Example 1: Find the analytical solution of the differential equation y’ = ay + b.
Solution: Enter the following in the command window:
s=dsolve(‘Dy=a*y+b’)
After pressing [enter], you get
s = -(b – C1*exp(a*t))/a
Example 2: Find the analytical solution of the differential equation dy/dx – y = -e^x.
Solution: Enter the following in the command window:
s=dsolve(‘Dy=y-exp(x)’, ‘x’)
After pressing [enter], you get
s =C1*exp(x) – x*exp(x)
🎀
Thank you for your attention~
I hope the above content is helpful to you!
🎀