Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Zadanie 1, grupa A - METODA EULERA
- clear
- function f=funkcja(x,y)
- f=2*y+8*x
- endfunction
- h=0.01
- x=1.5:h:3.5
- y(1)=2
- for i=1:2/h
- y(i+1)=y(i)+h*funkcja(x(i),y(i))
- end
- plot(x,y,'m')
- legend('METODA EULERA - h=0.01',4)
- xgrid
- //Zadanie 1, grupa B - METODA ZMODYFIKOWANA EULERA
- figure
- clear
- function f=funkcja(x,y)
- f=3*x^2-y
- endfunction
- h=0.01
- x=0:h:5
- y(1)=0
- for i=1:5/h
- y0=y(i)+h*funkcja(x(i),y(i))
- y(i+1)=y(i)+h*(funkcja(x(i),y(i))+funkcja(x(i+1),y0))/2
- end
- plot(x,y,'b')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement