pf n<
i k
function VaStplnt_MW_F elear *11
global SIGMA RHO BETA SIGMA = 10.; RHO = 28.; BETA = 8./3.;
FunFcn*'lienzeq'; » Dobre wyniki uzysku i o mu
tfifldt' seed*, 7) ; >. Start generatora pseudolosoweg-
x0(1)=rand*30+5; x0(2)=rand*35-30; x0(3)=rand*40-5;
t0=0; tfinal=100; hroax = (tfinal - t0)/5; hmin = (tfinal - to)/200000; h = (tfinal - t0)/l00;
RelTol = 0.01;
t = t0;
X = x0(:); T-t;
X*x; Móc
e (t <= tfinal)
KI = feval(FunFcn, K2 = feval(FunFcn, K3 = feval(FunFcn,
t, x)*h;
t+h/2, x+Kl/2)*h;. t+h, x+2*K2-Kl)*h? rozwiązania («rr U)'
err_h = max(abs(Kl - 2*K2 + K3)/€) ; acc_err ■ RelTol*max(max(abs(x)),1.0); 3 if err_h <*acc_err, t » t + h;
x • X + (KI + 4*K2 + K3)/6;
T* (T, t] ;
X«(X,x] ;
•nd i Ł et r ht
waj i oś ..u fc rojku u ul ko wafli a if err_h -• 0.0
h - min(hmax,0.9*h*(acc_err/err_h)A(1/3));
•nd
figurę(L)
plot(T(l:(end-1)) ,diff (T)) przebieg kroku ealkowar f j gure(2)
plot3(X(li;) ,X (2, : ):,X(3,:)) trajektorie
grid on ..
Ij .non xdot « lorenzeq(t,x) global SIGMA RHO BETA
xdot - l-BETA*X(1)+X(2)*X(3); -SIGMA*(x(2)-x(3));... -x(2)*X(1)+RHO*x(2)-x(3)];