]> Creatis software - CreaPhase.git/blob - octave_packages/dataframe-0.9.1/@dataframe/private/df_allmeta.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / dataframe-0.9.1 / @dataframe / private / df_allmeta.m
1 function resu = df_allmeta(df, dim = [])
2
3   %# function resu = df_allmeta(df)
4   %# Returns a new dataframe, initalised with the all the
5   %# meta-information but with empty data
6
7   %% Copyright (C) 2009-2012 Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
8   %%
9   %% This file is part of Octave.
10   %%
11   %% Octave is free software; you can redistribute it and/or
12   %% modify it under the terms of the GNU General Public
13   %% License as published by the Free Software Foundation;
14   %% either version 2, or (at your option) any later version.
15   %%
16   %% Octave is distributed in the hope that it will be useful,
17   %% but WITHOUT ANY WARRANTY; without even the implied
18   %% warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
19   %% PURPOSE.  See the GNU General Public License for more
20   %% details.
21   %%
22   %% You should have received a copy of the GNU General Public
23   %% License along with Octave; see the file COPYING.  If not,
24   %% write to the Free Software Foundation, 51 Franklin Street -
25   %% Fifth Floor, Boston, MA 02110-1301, USA.
26   
27   %#
28   %# $Id: df_allmeta.m 9585 2012-02-05 15:32:46Z cdemills $
29   %#
30
31   resu = dataframe([]);
32
33   if (isempty(dim)), 
34     dim = df._cnt(1:2); 
35   else
36     dim = dim(1:2); %# ignore third dim, if any
37   endif
38
39   resu._cnt(1:2) = min(dim, df._cnt(1:2));
40   if (!isempty(df._name{1})),
41     resu._name{1} = df._name{1}(1:resu._cnt(1));
42     resu._over{1} = df._over{1}(1:resu._cnt(1));
43   endif
44   if (!isempty(df._name{2})),
45     resu._name{2} = df._name{2}(1:resu._cnt(2));
46     resu._over{2} = df._over{2}(1:resu._cnt(2));
47   endif
48   if (!isempty(df._ridx)),
49     if (size(df._ridx, 2) >= resu._cnt(2)),
50       resu._ridx = df._ridx(1:resu._cnt(1), :, :);
51     else
52       resu._ridx = df._ridx(1:resu._cnt(1), 1, :);
53     endif
54   endif
55   %# init it with the right orientation
56   resu._data = cell(size(df._data));
57   resu._rep = cell(size(df._rep));
58   resu._type = df._type(1:resu._cnt(2));
59   resu._src  = df._src;
60   resu._cmt  = df._cmt;
61   
62 endfunction