-
Use the Symbolic Arithmetic tool.
Start by defining the variable symbol. symss
xt;Use strings to define formulas.
eq1diff(x,t)
eq2diff(s,t)
Next is solving.
For example, if you are required to solve s now, the following ** can give the expression of s.
solution
solve(eq1,eq2,s);
Next, evaluate the value.
Start by assigning a value to the variable. x
t after that. result
eval(solution);
The solution can be found.
matlab
Symbolic operations.
-
This means that the differential equation does not show a solution, and is solved by numerical methods, such as a function such as ODE45.
Just one example (taken from the MATLAB help documentation).
Solve into the system of lower differential equations.
1. Establish the system of equations function.
function
dyrigid(t,y)dy
zeros(3,1);
acolumn
vectordy(1)
y(2)y(3);dy(2)
y(1)y(3);dy(3)
y(1)y(2);
2. Solve and plot.
t,y]ode45(@rigid,[0
1]);plot(t,y(:,1),'-',t,y(:,2),'-.',t,y(:,3),'.'Results.
-
The first method: use the dsolve function to find the symbolic solution of the differential equation (general solution): for some differential equations that are not very difficult and require a general solution, use the dsolve function to solve them.
1. Open the MATLAB software -- > click the New Script menu to create a new script file for writing the differential equation solver.
2. Enter the differential equation solver -- > click to save -- > click to run.
3. You can see the solution result in the command window of MATLAB, which is an expression about parameters a and b.
The second method: use the solver function in MATLAB (including ODE45, ODE23, ODE15S, etc.) to solve the numerical solution of differential equations, this method is the most commonly used method, and the numerical solution of the equation can be solved by using this method for equations that are difficult to solve by the dsolve function.
1. Open MATLAB--> create a new script file for writing the solver.
2. Enter the solver in the script file -- > click Save -- > click Run.
3. Here you need to write a function file to represent the equation -- > click to save -- > write the solver -- > click to save -- > click to run.
4. You can see the graph of the solved differential equation on the figure page.
-
If the system of differential equations given by the subject is solved by MATLAB, the numerical solution can be obtained by using the ODE function.
Solving process: The first step is to customize the function of the differential equation, odefun(t,x) according to the system of differential equations
The second step is to determine the range of t, such as tspan=[0 1];
The third step is to determine the initial conditions and determine the initial value of y0, that is, y0 = [100, 20];
The fourth step is to use the ODE45 function to obtain its numerical solution, i.e.
t,x] =ode45(@odefun,tspan,y0);
In the fifth step, use the plot function to plot the graphs of t-x(t) and t-y(t), that is.
plot(t,x(:,1),t,x(:,2));
After running the program, you can get the following result.
-
For general differential equations, you can use the dsolve() function to directly find the general solution of the differential equation.
For example, find the general solution of the following differential equation.
Solve**: syms y(t) a% variable masking statement.
eqn = diff(y,t,2) =a*y;% defines the bending equation.
ysol(t) = dsolve(eqn) % equation solved.
The solution process is fruitful with the macro.
-
To find the solution of differential equations in MATLAB, you can generally use the functions such as dsolve(), ode45(), and bvp4c() that come with the software.
There are two ways to solve ordinary differential equations in MATLAB: one is the symbolic solution, and the other is the numerical solution. The differential math problems at the undergraduate level can basically be solved by symbolic solutions.
The key command for solving symbolic solutions to ordinary differential problems with MATLAB is the dsolve command.
In this command, d can be used to denote the differentiation symbol, where d2 is the second-order differential, d3 is the third-order differential, and so on. It is worth noting that the differentiation is a derivative of the independent variable t by default, and it can be easily changed to a derivative of other variables in the command. ”
1. The dsolve function is often used to solve, simple differential equations (groups), such as y=dsolve('dy=y-2*t*y','y(0)=1')
2. The ODE45 function is often used to solve the numerical solution of differential equations (groups) of the initial value problem, such as func=@(t,y)y-2*t*y
t,y]=ode45(func,[0,40],1)
3. The BVP4C function is often used to solve the numerical solution of differential equations (groups) of boundary value problems, such as.
sol=bvp4c(odefun,bcfun,sinit)
4. In addition, you can also write Euler (polyline method), Runge-Kutta (Runge-Kutta method), etc. to solve differential equations (groups).
-
This shows that the solution of the differential equation is not shown, and the solution should be solved using numerical methods, such as a function such as ODE45 (from the MATLAB help document).
Solve into the system of lower differential equations.
1. Establish the system of equations function.
function dy = rigid(t,y)dy = zeros(3,1); a column vector
dy(1) = y(2) *y(3);
dy(2) = -y(1) *y(3);
dy(3) = * y(1) *y(2);
2. Solve and plot.
t,y] = ode45(@rigid,[0 12],[0 1 1]);
plot(t,y(:,1),'-',t,y(:,2),'-.',t,y(:,3),'.'Results.
-
The following example illustrates how to write a system of differential equations.
Solution 1: Create an M-file as follows:
function dy=rigid(t,y)dy=zeros(3,1);
dy(1)=y(2)*y(3);
dy(2)=-y(1)*y(3);
dy(3)=;
2. Take t0=0, tf=12, and enter the command:
t,y]=ode45('rigid',[0 12],[0 1 1]);
plot(t,y(:,1),'-',t,y(:,2),'*',t,y(:,3),'+')
In the figure, the graph of y1 is a solid line, the graph of y2 is a "*" line, and the graph of y3 is a "+" line.
-
Differential equations need to be discretized.
The practical applications of differential equations are as follows: >>>More
The calculation of the example problem should make the trembling error, the method is as follows, the ruler slips and respects the tomb carefully. >>>More
Summary. This equation belongs to the second-order differential equation. >>>More
Science Encyclopedia: Partial Differential Equations.
Personally, I think it is numerical analysis, multivariate statistics are easy to understand, and numerical analysis is a bit boring.