Home > . > ftest.m

ftest

PURPOSE ^

Copyright (C) 2001 Michel Juillard

SYNOPSIS ^

function ftest (s1,s2)

DESCRIPTION ^

 Copyright (C) 2001 Michel Juillard

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % Copyright (C) 2001 Michel Juillard
0002 %
0003 function ftest (s1,s2)
0004 
0005 global nvx nvy x y lag1
0006 
0007 if size(s1,1) ~= 2
0008     error ('Spcifiez deux fichiers pour la comparaison.') ;
0009 end
0010 
0011 for i = 1:2
0012     if ~ isempty(find(abs(s1(i,:)) == 46))
0013         error ('Entrez les noms de fichiers sans extensions.') ;
0014     end
0015 end
0016 
0017 s1 = [s1 [' ';' ']] ;
0018 file1 = [s1(1,1:min(find(abs(s1(1,:)) == 32))-1) '.BIN'] ;
0019 file2 = [s1(2,1:min(find(abs(s1(2,:)) == 32))-1) '.BIN'] ;
0020 
0021 fid=fopen(file1,'r') ;
0022 n1 = fread(fid,1,'int') ;
0023 n2 = fread(fid,1,'int') ;
0024 n3 = fread(fid,1,'int') ;
0025 lag1 = fread(fid,4,'int') ;
0026 nvx = fread(fid,[n1,n3],'int') ;
0027 x = fread(fid,[n1,n2],'float64') ;
0028 fclose(fid) ;
0029 nvx = setstr(nvx) ;
0030 
0031 fid=fopen(file2,'r') ;
0032 n1 = fread(fid,1,'int') ;
0033 n2 = fread(fid,1,'int') ;
0034 n3 = fread(fid,1,'int') ;
0035 lag2 = fread(fid,4,'int') ;
0036 nvy = fread(fid,[n1,n3],'int') ;
0037 y = fread(fid,[n1,n2],'float64') ;
0038 fclose(fid) ;
0039 nvy = setstr(nvy) ;
0040 
0041 if size(x,1) ~= size(y,1)
0042     error ('FTEST: The two files don''t have the same number of variables.');
0043 end
0044 
0045 for i = 1:size(x,1)
0046     if ~ strcmp(nvx(i,:),nvy(i,:))
0047         error ('FTEST: The two files don''t have the same  variables.') ;    
0048     end
0049 end
0050 
0051 if nnz(lag1 - lag2) > 0
0052     error ('FTEST: Leads and lags aren''t the same in both files.') ;
0053 end
0054 
0055 j = zeros(size(s2,1),1);
0056 for i=1:size(s2,1)
0057     k = strmatch(s2(i,:),nvx,'exact') ;
0058     if isempty(k)
0059       t = ['FTEST: Variable ' s2(i) 'doesn''t exist'] ;
0060       error (t) ;
0061     else
0062       j(i) =k;
0063     end
0064 end
0065 
0066 y = y(j,:) ;
0067 x = x(j,:) ;
0068 
0069 %06/18/01 MJ replaced beastr by strmatch

Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003