Home > Mateda2.0 > functions > generators > SaveFunctionValues.m

SaveFunctionValues

PURPOSE ^

[] = SaveFunctionValues(filename,NumberVar,ListFactors,Table)

SYNOPSIS ^

function [] = SaveFunctionValues(filename,NumberVar,ListFactors,Table)

DESCRIPTION ^

 []  = SaveFunctionValues(filename,NumberVar,ListFactors,Table)
 SaveFunctionValues:  Saves in a file the  values  of a given function whose structure is defined in ListFactors 
 INPUTS
 filename: name of the file with the function 
           File format: First the factor node number (starting at NumberVar and
           ending in NumbVar+NumberOfNodes). After each factor node number, the
           values of the function for the factor.
 NumberVar: Number of variables
 ListFactors: Each  row i stores the variables in the factor
 Tables{i}: Contains the values for each of the configurations of factor i 

 Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function []  = SaveFunctionValues(filename,NumberVar,ListFactors,Table)
0002 % []  = SaveFunctionValues(filename,NumberVar,ListFactors,Table)
0003 % SaveFunctionValues:  Saves in a file the  values  of a given function whose structure is defined in ListFactors
0004 % INPUTS
0005 % filename: name of the file with the function
0006 %           File format: First the factor node number (starting at NumberVar and
0007 %           ending in NumbVar+NumberOfNodes). After each factor node number, the
0008 %           values of the function for the factor.
0009 % NumberVar: Number of variables
0010 % ListFactors: Each  row i stores the variables in the factor
0011 % Tables{i}: Contains the values for each of the configurations of factor i
0012 %
0013 % Last version 8/26/2008. Roberto Santana (roberto.santana@ehu.es)
0014 
0015 totfactors = size(ListFactors,2);
0016 
0017 fid = fopen(filename,'wt');
0018  for i=1:totfactors,     
0019   fprintf(fid,'%d  \n',NumberVar+i-1); % Factor number
0020   sizetable = size(Table{i},2);    % Size of potential for factor i
0021   for j=1:sizetable,
0022    fprintf(fid,'%f \n',Table{i}(j)); %Potentials are printed
0023   end, 
0024  end, 
0025  
0026 fclose(fid);
0027

Generated on Fri 04-Dec-2009 13:38:29 by m2html © 2003