comparison findZeros.m @ 832:5573913a0949 feature/burgers1d

Merged with default, and updated +scheme/Burgers1D accordingly
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Tue, 11 Sep 2018 15:58:35 +0200
parents 8368beb0d1b3
children
comparison
equal deleted inserted replaced
831:d0934d1143b7 832:5573913a0949
1 % findZeros looks for solutions to the equation f(x)==0 within
2 % the limits lim with a granularity of h.
3 % Returns a sorted list of unique solutions.
4 function z = findZeros(f, lim, h)
5 n = ceil((lim(2)-lim(1))/h);
6 z0 = linspace(lim(1), lim(2), n);
7
8 z = zeros(1,n);
9
10 for i = 1:n
11 zt(i) = fzero(f, z0(i));
12 end
13
14 zt = sort(zt);
15
16 z = [];
17 for i = 1:n
18 if zt(i) < lim(1) || zt(i) > lim(2)
19 continue
20 end
21
22 if ~isempty(z) && abs(z(end) - zt(i)) < 1e-6
23 continue
24 end
25
26 z = [z zt(i)];
27 end
28
29 % z = unique(z);
30 end