RK4 - k2 = func(t + 0.5 * dt, z0 + 0.5 * k1) * dt; k3 =...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function [z] = RK4(func, tvec, z0) k1 = zeros(length(z0), 1); k2 = zeros(length(z0), 1); k3 = zeros(length(z0), 1); k4 = zeros(length(z0), 1); t = tvec(1); dt = tvec(2) - tvec(1); k1 = func(t, z0) * dt;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: k2 = func(t + 0.5 * dt, z0 + 0.5 * k1) * dt; k3 = func(t + 0.5 * dt, z0 + 0.5 * k2) * dt; k4 = func(t + dt, z0 + k3) * dt; z = z0 + (1/6) * (k1 + 2 * k2 + 2 * k3 + k4); return...
View Full Document

This note was uploaded on 09/18/2011 for the course ASE 167M taught by Professor Staff during the Spring '10 term at University of Texas at Austin.

Ask a homework question - tutors are online