how to solve first order nonlinear ode45 in a loop?
Mostrar comentarios más antiguos
I am trying to solve this nonlinear ode in a loop, first, I tried to use dsolve but it was unable to find explicit solution. Now I tried to use ode45 with limited span but it does not work also, please guys help.
imax = 50; npeop = 10; dt = 0.01
omfoot = 0.5*pi/2 + + randn(1,npeop)*0.1;
om = 0.2*pi;
Phi_i = 0.5*omfoot.*dt;
theta(npeop,1) = Phi_i;
u9 = zeros(npeop,imax);
theta = zeros(npeop,imax+1);
for i = 1:imax
syms theta_t(xt)
A = sqrt(xt^2 +xt^2/om);
Psi = asin(xt/A);
ode = (diff(theta_t,xt)) == Phi_i + 16*A*sin( Psi - theta_t + pi/2);
cond = theta_t(0) == theta(:,i);
xt_span = [u9(i) 0.001];
f = ode45(@(xt,theta_t) ode,xt_span,cond);
end
Respuestas (1)
Sulaymon Eshkabilov
el 19 de Ag. de 2019
0 votos
Your code has some flaws:
(1) theta(npeop,1) = Phi_i; is to be: theta(1:npeop,1) = Phi_i;
(2) Moreover, there are several undefined variables (om, u9, xspan) used within the loop that need to be defined in order to run your code.
(3) The variable ode representing DE can be defined via function file or function handle without syms that would be much faster and more efficient.
Good luck.
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!