Home > database > is_ensemble_datastruct.m

is_ensemble_datastruct

PURPOSE ^

Tests a variable to see if it conforms to the ensemble data struct

SYNOPSIS ^

function tf = is_ensemble_datastruct(inStruct)

DESCRIPTION ^

 Tests a variable to see if it conforms to the ensemble data struct
 specification. Returns 0 if it doesn't conform or 1 if it does.

 4/28/2007 - First Version, Stefan Tomic

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function tf = is_ensemble_datastruct(inStruct)
0002 % Tests a variable to see if it conforms to the ensemble data struct
0003 % specification. Returns 0 if it doesn't conform or 1 if it does.
0004 %
0005 % 4/28/2007 - First Version, Stefan Tomic
0006 
0007 if(~isstruct(inStruct))
0008   tf = 0;
0009   return
0010 end
0011 
0012 emptyStruct = ensemble_init_data_struct;
0013 
0014 emptyFieldNames = fieldnames(emptyStruct);
0015 inFieldNames = fieldnames(inStruct);
0016 
0017 if(length(emptyFieldNames) ~= length(inFieldNames))
0018   tf = 0;
0019   return
0020 end
0021 
0022 for ifld = 1:length(emptyFieldNames)
0023 
0024   if (~isfield(inStruct,emptyFieldNames{ifld}))
0025     tf = 0;
0026     return
0027   end
0028   
0029   emptyFieldType = class(emptyStruct.(emptyFieldNames{ifld}));
0030   inFieldType = class(inStruct.(emptyFieldNames{ifld}));
0031   
0032   if(~strcmp(emptyFieldType,inFieldType))
0033     tf = 0;
0034     return
0035   end
0036   
0037   
0038 end
0039 
0040 tf = 1;
0041 return

Generated on Wed 20-Sep-2023 04:00:50 by m2html © 2003