Having a system of three state I put the odes in a function and the script to solve the given function I'm getting NaN for output of ode45
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Sunil Ojwani
am 30 Nov. 2018
Kommentiert: Sunil Ojwani
am 30 Nov. 2018
my function is
function xdot=func4(t,x)
A=[0 1 0;0 0 1;-1 -2 -3]
B=[0 0;0 1;1 0]
C1=[0 1]'
C2=[1 0 ;0 1]
C3=[1 0]'

s=C1*x(1)+C2*[x(2);x(3)]+C3*x(1)^(3/4)
u=[x(1);0]+[x(2)+x(3);-x(3)]-[0;3/5*x(2)*x(1)^-2/5]-[0 0.1;0.1 0]*s/norm(s)+[x(1);0]+[2*x(2)+2.9*x(3);-0.1*x(2)-x(3)]
xdot=A*x+B*u
end
and by using ode 45 it give me nan state plese help me
tspan=[0 8]
x0=[0;-0.15;0.1]
[t,x]=ode45('func4',tspan,x0)
1 Kommentar
Akzeptierte Antwort
Walter Roberson
am 30 Nov. 2018
In your sub-expression
[0;3/5*x(2)*x(1)^-2/5]
you have the problem that x(1) can go to 0, leading to a division by 0.
x0=[0;-0.15;0.1]
... and x(1) being 0 is your initial condition so it is guaranteed to be a problem.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Ordinary Differential Equations finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!