Need alogrithm suggestion for simultaneous solution to a set of non linear equations with one 4th order ODE
Show older comments
Hello Every one and Good Morning,
I am amature student working on a topic and wanted a suggestion about the solution method or alogrithm for these set of equations in matlab.Sorry for my basic question but i have reviewed already ODE, Fsolve and DAE solution methods in Matlab.But unfortunatly, i did not reach a solution to this problem.
I am recently solving a problem with the following set of equations including one 4th order ODE.

The marked with the red are constants. And the one with black are function of x. The equations are non linear and the first equation is the 4th order ODE. As it is an intial value problem and therefore requires intial conditions to ODE as listed in the next matrix primarly constants. I want a solution to this problem for the parameters listed in output matrix for range described.
I need a suggestion about alogrithm to solve them simultaneously at every step x between 0 and 100.
Thank you so much for your advices, suggestions and examples.
Answers (1)
Etsuo Maeda
on 4 Oct 2019
Solving higher-order differential equation numerically, there might be 3 possible ways:
1. Symbolic Math Toolbox (dsolve)
syms y(t) A
% create equation
d1y = diff(y, t, 1);
d2y = diff(y, t, 2);
d3y = diff(y, t, 3);
eqn = d3y + d2y + d1y == A*y;
% set conditions
assume(A, 'real')
cond1 = d1y(0) == 1;
cond2 = d2y(0) == 0;
cond3 = d3y(0) == 0;
conds = [cond1, cond2, cond3];
% solve
symAns = dsolve(eqn, conds)
2. Symbolic Math Toolbox (odeToVectorField, matlabFunction) + MATLAB odeFun (ode45)
% substitution A = 3
eqn = subs(eqn, A, 3)
% reduce equation order from 3 to 1
V = odeToVectorField(eqn)
% create anoymous function for ode solver
M = matlabFunction(V, 'vars', {'t', 'Y'})
% set conditions
interval = [0 20];
yInit = [1 0 0];
% solve
odeAns = ode45(M, interval, yInit);
3. Simulink (Model Differential Algebraic Equations)

HTH
4 Comments
Iota
on 4 Oct 2019
Etsuo Maeda
on 4 Oct 2019
Hi Mr. or Ms. Iota,
Thank you very much for you kind explanations.
In my understanding, you want to solve simultaneous high-order ordinary differential equations.
Can you confirm following sample code for 2DOF Mass-spring-damper model in your MATLAB?
"odeToVectorField" in Symbolic Math Toolbox can be applied for simultaneous equations.
I believe it will help you to solve your complicated equations.
% create equation
syms z1(t) z2(t)
syms m1 m2 k1 k2 c1 c2 z0
m1 = 50;
m2 = 300;
k1 = 300000;
k2 = 21000;
c1 = 0;
c2 = 2400;
z0 = 0.001;
eq1 = diff(z2, t, 2) == m2^(-1)*(-k2*(z2-z1)-c2*(diff(z2, t, 1)-diff(z1, t, 1)));
eq2 = diff(z1, t, 2) == m1^(-1)*(k2*(z2-z1)+c2*(diff(z2, t, 1)-diff(z1, t, 1))-k1*(z1-z0));
% reduce equation order from 2 to 1
[ODE, VARS] = odeToVectorField(eq1, eq2)
% create anoymous function for ode solver
SYS = matlabFunction(ODE, 'vars', {'t', 'Y'})
% set conditions
y0 = [0 0 0 0];
tspan = [0 1];
% solve
[t,y] = ode45(SYS, tspan, y0);
% plot
plot(t, y)
HTH
Iota
on 4 Oct 2019
Etsuo Maeda
on 7 Oct 2019
Hi Iotah - san
I used to be a kind of sensei but I am not now :-)
I am not sure of your equation, but following idea will help you to solve:
[ODE, VARS] = odeToVectorField(eq1);
SYS = matlabFunction([ODE; eq2], 'vars', {'t', 'Y'})
Also, your equation seems to be transformed to 1 line equation, not simultaneous equation:
eq1 = diff(y(t), t, 4) == m(t)
m(t) = A(t) * B(t)
EQ1 = subs(eq1)
Additionaly, "simplify" function will help you.
HTH
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!