# Solving a highly non linear equation in Matlab

11 views (last 30 days)
Wissem-Eddine KHATLA on 4 Apr 2022
Answered: MOSLI KARIM on 18 Aug 2022
I would like to ask for some advices in order to solve numerically a highly non-linear differential equation that represents a height field measured on an experiment. This is the equation :
I would like to know :
• How realistic it would be to solve this equation numerically on Matlab ?
• What kind of tool can I use in order to do so ?
• Which kind of strategy would be efficient in order to solve it ?
Best regards,
Sam Chak on 4 Apr 2022
Edited: Sam Chak on 4 Apr 2022
Okay @Wissem-Eddine KHATLA, please type out the highly nonlinear ODE in MATLAB code first.
1. You can realistically solve the ODE in MATLAB and obtain the solution with a relatively good accuracy using a smaller step size.
2. Technically, there are various of ODE solvers and I think you can use the ode45 solver for this case.
3. The strategy as described in the examples in the link: https://www.mathworks.com/help/matlab/ref/ode45.html

Torsten on 4 Apr 2022
Edited: Torsten on 4 Apr 2022
It's "only" an ODE of degree 6.
Rewrite it as a system of first-order ODEs. You will need 6 initial or boundary conditions.
Depending on whether these conditions are set in one or two points, use ode45,ode15s as solvers for initial value problems or bvp4c as a solver for boundary value problems.

John D'Errico on 4 Apr 2022
Edited: John D'Errico on 4 Apr 2022
This is a differential equation. An ODE, because it involves derivatives wrt only one variable. It is high order, and nonlinear, so there will surely be NO analytical solution available. So do not even bother trying to use a tool like dsolve.
Convert the problem into a system of 6 ODE's. You can see examples of how to do so in the docs for tools like ODE45.
Finally, consider that NO solution can be obtained unless you have 6 initial conditions. This is because, as I said above, no analytical solution will be found. So you need 6 conditions, essentially on the function value and its derivatives.
Then you just call a tool like ODE45.
Note that if all of this seems to be completely meaningless to you, a complete foreign language, then you need to spend some time learning about ODEs (Ordinary Differential Equations).
Is it solvable? Probably so. In MATLAB, or in ANY computational environment, that is entirely up to you, and to the the time you will invest in it, and your skill at working with ODEs. Will it take some effort? Probably, and that is true no matter where you try to solve it, and what tools you use. There are many tools and methods that can be used to solve ODEs. Surely some of them will work on your problem.
MOSLI KARIM on 18 Aug 2022
here is my proposal for your problem
here is my proposal for your problem
Unrecognized function or variable 'here'.
function ODE_ordre6
tspan=[1 10];
y0=[1;1;1;1;1;1];
option=odeset('relto',1*10^-6);
[eta,F]=ode45(@fct,tspan,y0,option );
eta
F
plot(eta,F(:,1),'r-o',eta,F(:,2),'o-b',eta,F(:,3),'y-o',eta,F(:,4),'g-o',eta,F(:,5),'k-o',eta,F(:,6),'c-o')
xlabel('\eta')
ylabel('F')
legend('F','F(:,1)','F(:,2)','F(:,3)','F(:,4)','F(:,5)','F(:,6)')
% table(F1,F2,F3,F4,F5,F6
function dxdy=fct(eta,y)
dxdy=[y(2);y(3);y(4);y(5);y(6);((5*y(1)-4*eta*y(2)-3*(y(2)^2)*y(6))/y(1))];
end
end

MOSLI KARIM on 18 Aug 2022
here is my proposal for your problem
Unrecognized function or variable 'here'.
%%%%%%%%%%%%%%%%%% CODE MATLAB
function ODE_ordre6
tspan=[1 10];
y0=[1;1;1;1;1;1];
option=odeset('relto',1*10^-6);
[eta,F]=ode45(@fct,tspan,y0,option );
eta
F
plot(eta,F(:,1),'r-o',eta,F(:,2),'o-b',eta,F(:,3),'y-o',eta,F(:,4),'g-o',eta,F(:,5),'k-o',eta,F(:,6),'c-o')
xlabel('\eta')
ylabel('F')
legend('F','F(:,1)','F(:,2)','F(:,3)','F(:,4)','F(:,5)','F(:,6)')
% table(F1,F2,F3,F4,F5,F6
function dxdy=fct(eta,y)
dxdy=[y(2);y(3);y(4);y(5);y(6);((5*y(1)-4*eta*y(2)-3*(y(2)^2)*y(6))/y(1))];
end
end

### 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!

Translated by