In: Physics
Solve Kepler's Equations Using Euler's Method in matlab.
The following is a Matlab program to solve differential equations numerically using Euler's Method . I will explain how to use it at the end:
| %function t=t(n,t0,t1,y0) |
| function y=y(n,t0,t1,y0) |
| h=(t1-t0)/n; |
| t(1)=t0; |
| y(1)=y0; |
| for i=1:n |
| t(i+1)=t(i)+h; |
| y(i+1)=y(i)+h*ex(t(i),y(i)); |
| end; |
| V=[t',y'] |
| plot(t,y) |
| title('satya') |
| %x is a function of t and y is the first derivative x'(t) |
| function y=y(t,x) |
| y=(t^2-x^2)*sin (x); |