/
trigpts.m
44 lines (35 loc) · 1.02 KB
/
trigpts.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
function [x, w] = trigpts(n, dom)
%TRIGPTS Equally spaced points.
% TRIGPTS(N) returns N equispaced points in [-1, 1).
%
% TRIGPTS(N, D), where D is vector of length 2 and N is a scalar integer,
% returns N equispaced points in the interval [D(1),D(2)).
%
% [X, W] = TRIGPTS(N) or [X, W] = TRIGPTS(N, D) returns also a row vector
% of the weights for the trapezoidal rule.
%
% See also CHEBPTS, LEGPTS, JACPTS, LAGPTS, and HERMPTS.
% Copyright 2017 by The University of Oxford and The Chebfun Developers.
% See http://www.chebfun.org/ for Chebfun information.
% Special case (no points).
if ( nargin < 1 || n <= 0 )
x = [];
w = [];
return
end
x = linspace(-pi, pi, n+1).';
x = x./pi;
x = (x-x(end:-1:1))/2; % enforce symmetry
x(end) = [];
if ( nargout > 1 )
w = trigtech.quadwts(n);
end
if ( nargin > 1 )
% Map to the right domain:
x = diff(dom(1:2))*x/2 + mean(dom(1:2));
if ( nargout > 1 )
% Map to the right domain:
w = w * diff(dom(1:2))/2;
end
end
end