Institut de Robòtica i Informàtica Industrial

GetData

PURPOSE ^

Loads and, if necessary, generates data from experiments.

SYNOPSIS ^

function data=GetData(fname,GenerateData)

DESCRIPTION ^

   Loads and, if necessary, generates data from experiments.

   Checks if the file of results 'fname' exists. If not, (parameter-less) 
   function GenerateData is executed to produce the file.
   
   Then the file is loaded and its content returned to the caller.

   This function is used when generating the figures. The data for the
   figures takes very long to be computed and, thus, it is pre-computed
   whenever possible. This function is used to check whether or not some
   results are already pre-computed with the aim of saving computation 
   as much as possible.

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:

SOURCE CODE ^

0001 function data=GetData(fname,GenerateData)
0002 %   Loads and, if necessary, generates data from experiments.
0003 %
0004 %   Checks if the file of results 'fname' exists. If not, (parameter-less)
0005 %   function GenerateData is executed to produce the file.
0006 %
0007 %   Then the file is loaded and its content returned to the caller.
0008 %
0009 %   This function is used when generating the figures. The data for the
0010 %   figures takes very long to be computed and, thus, it is pre-computed
0011 %   whenever possible. This function is used to check whether or not some
0012 %   results are already pre-computed with the aim of saving computation
0013 %   as much as possible.
0014 
0015   f=fopen(fname);
0016   if f<0
0017     fprintf('Data is not pre-computed: Generating it\n');
0018     GenerateData();
0019     f=fopen(fname);
0020     if f<0
0021       error('Data Missing');
0022     end
0023   end
0024   fclose(f);
0025   fprintf('Data is already computed: Reading it\n');
0026   data=load(fname);
0027


Institut de Robòtica i Informàtica Industrial

Generated on Wed 05-Aug-2009 15:05:21 by m2html © 2003