error using ode45 from dynamic simulation
Afficher commentaires plus anciens
Hi, I am trying to use ODE45. Could you please tell me what I am doing wrong. Thanks
t0 = 0; %Initial Simulation Time
tf = 10; %Final Simulation Time
x10 = 0; %Initial condition
[t,x]=ode45('f_nonlinear',[t0,tf],[x10]);
%Plot the data.
hold on
plot(t,x(:,1))
and the other file is here:
function xout = f_nonlinear(t,x)
J =1;
R = 1;
k = 1;
m=1;
b=1;
g=9.8;
L=1;
v=1;
xout(1) = x(2);
xout(2) = k*x(3)/J -m*g*l*sin(x(1))/J -b*x(2)/J;
xout(3)= (-R*x(3)-k*x(2))/L +v/L;
xout = xout';
1 commentaire
Azzi Abdelmalek
le 18 Fév 2013
Post the error message
Réponses (1)
Azzi Abdelmalek
le 18 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 18 Fév 2013
1 vote
What is l in: xout(2) = k*x(3)/J -m*g* l *sin(x(1))/J -b*x(2)/J;
1 commentaire
Cyrus Mahin
le 18 Fév 2013
Catégories
En savoir plus sur Ordinary 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!