Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. function [t,y]=prob5(inter,y0,n)
  2. t(1)=inter(1);
  3. y(1,:)=y0;
  4. h=(inter(2)-inter(1))/n;
  5. for i=1:n
  6. t(i+1)=t(i)+h;
  7. y(i+1,:)=eulerstep(t(i),y(i,:),h);
  8. end
  9. plot(t,y(:,1),t,y(:,2));
  10. function y=eulerstep(t,y,h)
  11. y=y+h*ydot(t,y);
  12. function z=ydot(t,y)
  13. z(1)=y(1)+3*y(2);
  14. z(2)=2*y(1)+2*y(2);
  15.  
  16. %APELARE : [t,y]=prob5([0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement