diff diracDiscr.m @ 646:0990765e3e4d feature/d1_staggered

Fix bug in diracDiscr
author Martin Almquist <malmquist@stanford.edu>
date Tue, 14 Nov 2017 15:01:50 -0800
parents a5307adc6177
children 9e5dd0d3cf60
line wrap: on
line diff
--- a/diracDiscr.m	Tue Nov 14 14:28:35 2017 -0800
+++ b/diracDiscr.m	Tue Nov 14 15:01:50 2017 -0800
@@ -6,7 +6,14 @@
 tot = m_order+s_order;
 S = [];
 M = [];
-poss = find(tot*h/2>eta);
+poss = find(tot*h/2 >= eta);
+
+% Ensure that poss is not too long
+if length(poss) == (tot + 2)
+    poss = poss(2:end-1);
+elseif length(poss) == (tot + 1)
+    poss = poss(1:end-1);
+end
 
 % Use first tot grid points
 if length(poss)<tot && eta(end)>eta(1)
@@ -49,7 +56,6 @@
     end
 end
 
-
 A = [M;S];
 
 d = A\b;