ODE solver with time-dependent term
Afficher commentaires plus anciens
Do MATLAB ODE solvers usually change the _ * time-dependent terms*_ in the Ordinary differential set of equations? As a simple example, consider the following example from [ 1 ]
function xdot = fun1(t,x,beta,omega,A,w0,theta)
% The time-dependent term is A * sin(w0 * t - theta)
sicw=A * sin(w0 * t - theta);
xdot(2)= -beta*x(2) + omega^2 * x(1) + sicw;
xdot(1) = x(2);
xdot=[xdot(:);sicw];
% To make xdot a column
% End of FUN1.M
end
Where calling the function as follow:
beta = .1;
omega = 2;
A = .1;
w0 = 1.3;
theta = pi/4;
X0 = [0 1 0]';
t0 = 0;
tf = 20;
options = [];
[t,y]=ode23(@fun1,[t0,tf],X0,options,beta,omega,A,w0,theta);
When I try to plot the time-dependent term,
sicw=A * sin(w0 * t - theta);
Outside the function or as the third column of the output "y" output versus "t", I get different graphs:

In this example, at least the overall behavior of the graph is preserved, However in my actual code, where the time-dependent term is again a sinusoid,
sicw=0.05e9*sin(2*pi*t/(10e-9))+0.05e9;
the output is worse and even the behavior is not the same!

I don't really know what is going on! Any help is appreciated.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!