aboutsummaryrefslogtreecommitdiffstats
path: root/Part 1/heun_temp.m
diff options
context:
space:
mode:
Diffstat (limited to 'Part 1/heun_temp.m')
-rw-r--r--Part 1/heun_temp.m13
1 files changed, 13 insertions, 0 deletions
diff --git a/Part 1/heun_temp.m b/Part 1/heun_temp.m
new file mode 100644
index 0000000..9a49d4a
--- /dev/null
+++ b/Part 1/heun_temp.m
@@ -0,0 +1,13 @@
+function [y, t] = heun_temp(f,a,b,ya,n)
+h = (b - a) / n;
+halfh = h / 2;
+y(1,:) = ya;
+t(1) = a;
+for i = 1 : n
+ t(i+1) = t(i) + h;
+ g = f(t(i),y(i,:));
+ z = y(i,:) + h * g;
+ y(i+1,:) = y(i,:) + halfh * ( g + f(t(i+1),z) );
+end;
+
+%func,t0,tf,i0,step_size \ No newline at end of file