solve a system of nonlinear differential equations whit initial conditions
1 次查看(过去 30 天)
显示 更早的评论
i need to solve the system diff(xl,t,2)+(beta*(1+xl^2)*diff(xl,t))+xl +(delta/2*xl) == alpha*(diff(xr,t)+diff(xl,t)) diff(xr,t,2)+(beta*(1+xr^2)*diff(xr,t))+xr -(delta/2*xr) == alpha*(diff(xr,t)+diff(xl,t)) with the conditions xl(0) == 1 xr(0) == 1 xl'(0) == 0 xr'(0) and the parameters: alpha=0.5;beta=0.3; delta=0.
i try with:
% inizialize patameters
alpha=0.5
beta=0.3
delta=0;
syms xl(t) xr(t) ;
eqn1 = diff(xl,t,2)+(beta*(1+xl^2)*diff(xl,t))+xl +(delta/2*xl) == alpha*(diff(xr,t)+diff(xl,t));
eqn2 = diff(xr,t,2)+(beta*(1+xr^2)*diff(xr,t))+xr -(delta/2*xr) == alpha*(diff(xr,t)+diff(xl,t));
eqns =[eqn1, eqn2];
dl= diff(xl,t);
dr= diff(xr,t);
cond1 = xl(0) == 1;
cond2 = xr(0) == 1;
cond3 = dl(0) == 0;
cond4 = dr(0) == 0;
cond = [cond1, cond2, cond3, cond4];
[Sol_xl(t),Sol_xr(t)]= dsolve(eqns,cond);
but goves me the errors:
Warning: Unable to find symbolic solution.
> In dsolve (line 209)
In (line 20)
Error using sym/subsindex (line 857)
Invalid indexing or function definition. Indexing must follow MATLAB indexing. Function arguments must be symbolic variables, and function body must be sym expression.
Error in (line 20)
[Sol_xl(t),Sol_xr(t)]= dsolve(eqns,cond);
0 个评论
回答(1 个)
Ishan
2022-11-4
If dsolve cannot find an explicit solution of a differential equation analytically, then it returns an empty symbolic array. You can solve the differential equation by using MATLAB numerical solver, such as ode45. For more information, see Solve a Second-Order Differential Equation Numerically.
Likely the only way to solve it is to use odeToVectorField and matlabFunction functions to create an anonymous function to use with the numeric ODE solvers, such as ode45 or ode15s:
You may start with this for your case : -
alpha=0.5;
beta=0.3;
delta=0;
syms y(t) x(t)
eqn1 = diff(x,t,2)+(beta*(1+x^2)*diff(x,t))+x +(delta/2*x) == alpha*(diff(y,t)+diff(x,t));
eqn2 = diff(y,t,2)+(beta*(1+y^2)*diff(y,t))+y -(delta/2*y) == alpha*(diff(y,t)+diff(x,t));
eqns =[eqn1, eqn2];
[V,S] = odeToVectorField(eqns)
M = matlabFunction(V,'vars', {'t','Y','X'})
%[t,y] = ode45(odefun,tspan,y0) %configure the ode solver as per your required given initial values.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!