function obj = allocateRows(obj, num_rows)
% allocateRows - Preallocates a NaN-filled num_rows rows in tests_db.
% obj = allocateRows(obj, num_rows)
% Overwrites the database by allocating a new matrix of the desired number
% of rows to speed up filling up the data matrix using
% assignRowsTests. Using addRow after this operation is still expensive.
% The method of allocating a matrix, filling it up, and then providing it to
% the tests_db constructor is the preferred method of creating tests_db
% obj: A tests_db object.
% num_rows: The predicted number of observations for this tests_db.
% obj: The new tests_db object.
% See also: assignRowsTests, addRow, setRows, tests_db
% Author: Cengiz Gunay <email@example.com>, 2004/09/08
% Copyright (c) 2007 Cengiz Gunay <firstname.lastname@example.org>.
% This work is licensed under the Academic Free License ("AFL")
% v. 3.0. To view a copy of this license, please look at the COPYING
% file distributed with this software or visit
if dbsize(obj, 1) ~= 0 && dbsize(obj, 2) ~= 0
error(['Database is not empty! This operation erases ', ...
'all contents of the DB.']);
obj.data = repmat(NaN, num_rows, length(fieldnames(obj.col_idx)));