1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
clc clear x(1)=1; y(1)=2; h=0.2; for i=1:4; x(i+1)=x(i)+h; a(i)=h*(1/(x(i)+y(i))) b(i)=h*(1/(x(i)+(h/2)+y(i)+(a(i)/2))) c(i)=h*(1/(x(i)+(h/2)+y(i)+(b(i)/2))) d(i)=h*(1/(x(i)+h+y(i)+c(i))) y(i+1)=y(i)+(1/6)*(a(i)+2*b(i)+2*c(i)+d(i)) end % clc % clear % x(1)=0; % y(1)=2; % h=0.05; % for i=1:20 % x(i+1)=x(i)+h % a(i)=h*(1/(x(i)+y(i))) % b(i)=h*(1/(x(i)+(h/2)+y(i)+a(i)/2)) % c(i)=h*(1/(x(i)+(h/2)+y(i)+b(i)/2)) % d(i)=h*(1/(x(i)+h+y(i)+c(i))) % y(i+1)=y(i)+(a(i)+2*b(i)+2*c(i)+d(i))/6 % end plot(x,y) % grafik çiz |
Kodları online denemek için
http://octave-online.net/