Mercurial > repos > public > sbplib
comparison +util/integral_vec.m @ 86:3c39dd714fb6
In Curve: Added numerical FD differentiation if derivative is not supplied. Added arc length computation based on the derivative. Added arc length parameterization (but this function is very slow.). In +util: Added fzero_vec.m and integral_vec.m, which call fzero and integral but take vector arguments.
author | Martin Almquist <martin.almquist@it.uu.se> |
---|---|
date | Sun, 29 Nov 2015 14:28:53 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
80:14bf01b7a068 | 86:3c39dd714fb6 |
---|---|
1 function I = integral_vec(f,a,b) | |
2 % Wrapper around the built-in function integral that | |
3 % handles multiple limits. | |
4 | |
5 Na = length(a); | |
6 Nb = length(b); | |
7 assert(Na == 1 || Nb == 1 || Na==Nb,... | |
8 'a and b must have same length, unless one is a scalar.'); | |
9 | |
10 if(Na>Nb); | |
11 I = zeros(size(a)); | |
12 for i = 1:Na | |
13 I(i) = integral(f,a(i),b); | |
14 end | |
15 elseif(Nb>Na) | |
16 I = zeros(size(b)); | |
17 for i = 1:Nb | |
18 I(i) = integral(f,a,b(i)); | |
19 end | |
20 else | |
21 I = zeros(size(b)); | |
22 for i = 1:Nb | |
23 I(i) = integral(f,a(i),b(i)); | |
24 end | |
25 end | |
26 end |