How to solve first-order nonlinear differential equation where the solution is coupled with an integral?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Califfo
le 3 Juil 2019
Commenté : David Goodmanson
le 8 Juil 2019
I'm trying to solve this nonlinear ODE
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227333/image.png)
- where q is a nonlinear function, solution of ODE;
represents the velocity and it is equal to:
;
- tis the time:
- the over dot denotes the derivative with respect to time;
- the initial condition is
λ is a degradation parameter of function q and it is equal to: ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227338/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/227338/image.png)
The integral depends to the solution of ODE.
So I have written this code, but the solution is bad because there isn't degradation of q function
clc
clear
close all
tspan = [0 pi*5];
q0 = 0;
x=@(t)t.*sin(t);
xdot=@(t)t.*cos(t)+sin(t);
lambda = @(t,q) 1+0.01*integral(@(t)q*xdot(t),0,t,'ArrayValued',true);
qdot = @(t,q) xdot(t)*(1-(abs(q)*lambda(t,q)*(0.5+0.5*sign(xdot(t)*q))));
[t,q] = ode45(qdot, tspan, q0);
plot(x(t),q,'LineWidth',2)
0 commentaires
Réponse acceptée
David Goodmanson
le 4 Juil 2019
Modifié(e) : David Goodmanson
le 4 Juil 2019
Hi Califfo;
This may be in line with what you want. At least it's changing size It's based on the idea that you know not only qdot, but also lambdadot. That quanity is simply the integrand, .01*q*xdot, and you know that lambda has a starting value of 1. You can make a vector from [q, lambda], which I arbitrarily called z, and then use ode45..
tspan = [0 pi*10];
g0 = 0;
lam0 = 1;
z0 = [g0; lam0];
[t,z] = ode45(@fun, tspan, z0);
x = t.*sin(t);
plot(x,z(:,1))
function zdot = fun(t,z)
xdot = t*cos(t)+sin(t);
q = z(1);
lam = z(2);
qdot = xdot*(1-(abs(q))*(lam/2)*(1+ sign(xdot*q)));
lamdot = 0.01*q*xdot;
zdot = [qdot; lamdot]
end
2 commentaires
David Goodmanson
le 8 Juil 2019
Yes, let me and the website know if there is anything that needs clarification.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!