function [x,y,hh]=change_step_RK(fun,x0,xn,y0,h)global x; AbsTol=0.0001; xt=x0:h:xn; m=length(xt); x=xt;y=zeros(m,1);hh=h*ones(m,1); y(1)=y0; x y hh for n=1:m-1 [x1,y1]=RK_f(fun,x0,x(n+1),y0,hh(n+1)) [x2,y2]=RK_f(fun,x0,x(n+1),y0,hh(n+1)/2)while abs(y1-y2)>AbsTol; x1=x2;y1=y2;hh(n+1)=hh(n+1)/2;[x2,y2]=RK_f(fun,x0,x(n+1),y0,hh(n+1)/2);end x(n+1)=x2; y(n+1)=y2; end