%
%  enter_H_complex.m  ver 1.0  September 22, 2012
%
function[H,df,nf,ncontinue]=enter_H()
%
disp(' Select complex transfer function input method ');
disp('   1=external ASCII file (three columns: freq real imag) ');
disp('   2=file preloaded into Matlab (two columns: freq complex) ');
disp('   3=Excel file ,(two columns: freq complex) ');
file_choice = input('');
%
if(file_choice==1)
        [filename, pathname] = uigetfile('*.*');
        filename = fullfile(pathname, filename);
        fid = fopen(filename,'r');
        THM = fscanf(fid,'%g %g %g',[3 inf]);
        THM=THM';
        H(:,1)=THM(:,1);
        H(:,2)=THM(:,2)+(1i)*THM(:,3);
end
if(file_choice==2)
        FS = input(' Enter the matrix name:  ','s');
        THM=evalin('caller',FS);
        H=THM;
end
if(file_choice==3)
        [filename, patname] = uigetfile('*.*');
        xfile = fullfile(pathname, filename);
%        
        THM = xlsread(xfile);
        H=THM;
%         
end
%
sz=size(H);
if(sz(2)>sz(1))
    H=H';
end
%
nf=max(size(H));
%
df=(H(nf,1)-H(1,1))/(nf-1);
%
df_max=max(diff(H(:,1)));
df_min=min(diff(H(:,1)));
%
ncontinue=0;
if(((df_max-df_min)/df)>0.01)
    disp(' ')
    disp(' Warning:  frequency step is not constant.  Continue calculation? 1=yes 2=no ')
    ncontinue=input(' ');
end