solve a system of nonlinear differential equations whit initial conditions

조회 수: 4 (최근 30일)
Luca Monticelli
Luca Monticelli 2021년 2월 6일
답변: Ishan 2022년 11월 4일
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);

답변 (1개)

Ishan
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)
V = 
S = 
M = matlabFunction(V,'vars', {'t','Y','X'})
M = function_handle with value:
@(t,Y,X)[Y(2);-Y(1)+Y(2)./2.0+Y(4)./2.0-Y(2).*(Y(1).^2.*(3.0./1.0e+1)+3.0./1.0e+1);Y(4);Y(2)./2.0-Y(3)+Y(4)./2.0-Y(4).*(Y(3).^2.*(3.0./1.0e+1)+3.0./1.0e+1)]
%[t,y] = ode45(odefun,tspan,y0) %configure the ode solver as per your required given initial values.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by