Mercurial > repos > public > sbplib
comparison diracDiscr.m @ 1242:ff613067dec6 feature/dirac_discr
Merge heads
author | Martin Almquist <malmquist@stanford.edu> |
---|---|
date | Tue, 19 Nov 2019 17:04:32 -0800 |
parents | d1b201fe328e a0940c1db455 |
children | 0a1c64d3c717 |
comparison
equal
deleted
inserted
replaced
1241:d1b201fe328e | 1242:ff613067dec6 |
---|---|
30 | 30 |
31 | 31 |
32 % Helper function for 1D delta functions | 32 % Helper function for 1D delta functions |
33 function ret = diracDiscr1D(x_s, x, m_order, s_order, H) | 33 function ret = diracDiscr1D(x_s, x, m_order, s_order, H) |
34 | 34 |
35 m = length(x); | |
36 | |
37 % Return zeros if x0 is outside grid | 35 % Return zeros if x0 is outside grid |
38 if x_s < x(1) || x_s > x(end) | 36 if x_s < x(1) || x_s > x(end) |
39 ret = zeros(size(x)); | 37 ret = zeros(size(x)); |
40 return | 38 return |
41 else | 39 else |
42 tot_order = m_order+s_order; %This is equiv. to the number of equations solved for | 40 tot_order = m_order+s_order; %This is equiv. to the number of equations solved for |
43 S = []; | 41 S = []; |
44 M = []; | 42 M = []; |
45 | 43 |
46 % Get interior grid spacing | 44 % Get interior grid spacing |
47 middle = floor(m/2); | 45 middle = floor(length(x)/2); |
48 h = x(middle+1) - x(middle); % Use middle point to allow for staggered grids. | 46 h = x(middle+1) - x(middle); % Use middle point to allow for staggered grids. |
49 | 47 |
50 index = sourceIndices(x_s, x, tot_order, h); | 48 index = sourceIndices(x_s, x, tot_order, h); |
51 | 49 |
52 polynomial = (x(index)-x(index(1)))/(x(index(end))-x(index(1))); | 50 polynomial = (x(index)-x(index(1)))/(x(index(end))-x(index(1))); |