-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_fd_basis.m
64 lines (51 loc) · 1.91 KB
/
create_fd_basis.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function basisobj = create_fd_basis(fdobj)
%CREATE_FD_BASIS Creates a functional data object basis.
% Arguments ...
% FD ... A replicated univariate functional data object. The replicated
% functions are the basis functions for representing data. A
% popular source of such a basis would the the FD object
% containing eigenfunctions arising from a functional PCA.
% Returns
% BASISOBJ ... a functional data basis object
%
% See also BASIS, CREATE_BSPLINE_BASIS, CREATE_CONSTANT_BASIS,
% CREATE_EXPONENTIAL_BASIS, CREATE_FDVARIANCE_BASIS, CREATE_FOURIER_BASIS,
% CREATE_MONOMIAL_BASIS, CREATE_POLYGONAL_BASIS, CREATE_POLYNOMIAL_BASIS,
% CREATE_POWER_BASIS, CREATE_POLYGONAL_BASIS, CREATE_FEM_BASIS,
% CREATE_PRODUCT_BASIS, CREATE_TP_BASIS
% Last modified 3 October 2011
% Default basis for missing arguments: a flat line and a line with slope 1
if nargin==0
type = 'fd';
rangeval = [0,1];
nbasis = 2;
params = fd([1, 0; 0, 1],create_monomial_basis([0,1],2));
dropind = [];
quadvals = [];
values = {};
basisvalues = {};
basisobj = basis(type, rangeval, nbasis, params, ...
dropind, quadvals, values, basisvalues);
return
end
if ~strcmp(class(fdobj), 'fd')
error('Argument is not a functional data object');
end
% extract the basis
basisobj = getbasis(fdobj);
% extract the coefficient matrix
coefmat = getcoef(fdobj);
if length(size(coefmat)) > 2
error('Argument is not a univariate functional data object');
end
% construct basis object
type = 'fd';
rangeval = getbasisrange(basisobj);
nbasis = size(coefmat,2);
params = fdobj;
dropind = [];
quadvals = [];
values = {};
basisvalues = {};
basisobj = basis(type, rangeval, nbasis, params, ...
dropind, quadvals, values, basisvalues);