b. Solution
Any method, such as Euler’s, may now be applied to each first order equation in turn. Thusly:
.
The MatLab® code might look like this:
z(1) = 0.0
z(2) = xo
z(3) = vo
h = 0.01
for i=1:100
z(1) = z(1) + h
z(2) = z(2) +h*z(3)
z(3) = z(3) + h*f(z(1),z(2),z(3))
end
c. Example
Share with your friends: |