Advertisement
kevin2458

Euler MATLAB

Dec 10th, 2016
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.62 KB | None | 0 0
  1. fprintf('\n \tRESOLUCION DE ECUACIONES DIFERENCIALES POR ELMETODO DE EULER\n')
  2.  
  3. f=input('\nIngrese la ecuacion diferencial de la forma: dy/dx=f(x,y)\n','s');
  4.  
  5. x0=input('\nIngrese el primer punto x0:\n');x1=input('\nIngrese el segundo punto x1:\n');
  6.  
  7. y0=input('\nIngrese la condicion inicial y(x0):\n');
  8.  
  9. n=input('\nIngrese el numero de pasos n:\n');
  10.  
  11. h=(x1-x0)/n;xs=x0:h:x1;y1=y0;
  12.  
  13. fprintf('\n''it x0 x1 y1');
  14.  
  15. for i=1:nit=i-1;
  16.  
  17. x0=xs(i);x=x0;x1=xs(i+1);
  18.  
  19. y=y0;
  20.  
  21. y1=y0+h*eval(f);
  22.  
  23. fprintf('\n%2.0f%10.6f%10.6f%10.6f\n',it,x0,x1,y1);
  24.  
  25. y0=y1;
  26.  
  27. endf
  28.  
  29. printf('\n El punto aproximado y(x1) es = %10.6f\n',y1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement