Reads a file containing the alpha and beta coefficients and returns them in an array.
0001 function [gpsStartMin,alpha,beta]=read_alphabetafile(filename,gpsRange,duration) 0002 % 0003 % Reads a file containing the alpha and beta coefficients 0004 % and returns them in an array. 0005 % 0006 % 0007 0008 % Assign Boolean values (note not the usual ones) 0009 true = 0; 0010 false = ~0; 0011 0012 % Input data checking 0013 if nargin ~= 3 0014 error('[gpsStartSec,alpha,beta] = read_alphabetafile(filename,gpsRange,durationSec)'); 0015 end 0016 0017 %filename = varargin{1}; 0018 %gpsStart = varargin{2}; 0019 %durationSec = varargin{3}; 0020 0021 %P IF # columns in GPS Range entry = 1 (indicating #,#) 0022 %P IF there is a duration numeric entry 0023 %P SET gpsStartSec to first entry 0024 %P SET durationSec to second entry 0025 %P SET GPS range flag 0026 %P END 0027 %P ELSE 0028 %P SET gpsOffsetSec to 1st element of input vector 0029 %P SET gpsEndSec to last element of input vector 0030 %P SET durationSec = gpsEndSec - gpsOffsetSec 0031 %P ENDIF 0032 %P ENDIF 0033 isGpsRange = false; 0034 [mrows,ncols] = size(gpsRange); 0035 if(ncols == 1) 0036 if(nargin>2) 0037 if(isa(duration,'numeric')) 0038 gpsOffsetSec = gpsRange; 0039 durationSec = duration; 0040 gpsEndSec = gpsOffsetSec + durationSec; 0041 isGpsRange = true; 0042 end 0043 end 0044 else 0045 gpsOffsetSec = gpsRange(1); 0046 gpsEndSec = gpsRange(ncols); 0047 durationSec = gpsEndSec - gpsOffsetSec; 0048 isGpsRange = true; 0049 end 0050 %P IF gps Range flag not set 0051 %P FLAG as error 0052 %P exit 0053 %P ENDIF 0054 %P SET start time = channel start time + GPS offset 0055 %P USE framelist function to get list of frame files covering 0056 %P start time to (start time + duration) 0057 if(isGpsRange ~= true) 0058 warning('Bad GPS range format'); 0059 return; 0060 end 0061 0062 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0063 % 0064 % Supported format types 0065 % 0066 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0067 0068 % Patrick's alphabeta file format 0069 0070 % format_string='%d%f%f'; 0071 % parameter='headerlines'; 0072 % no_of_header_lines = 4; 0073 0074 % calibration team's file format 0075 format_string='%f%f%f%f%f'; 0076 % Previous versions of this had '%d%f%f%d%f' which returned extra lines 0077 % with 1's or 0's in them - fixed 1/22/03 by stuver 0078 parameter='headerlines'; 0079 no_of_header_lines = 1; 0080 0081 % 0082 % 0083 % Main starts here 0084 % 0085 % 0086 0087 % Load in the alphabeta data file 0088 %[gpsStartMin,alpha,alphabeta] = ctextread(filename,format_string,parameter,no_of_header_lines); 0089 %patrick 0090 %[gpsStartMin,alpha,alphabeta] = textread(filename,format_string,parameter,no_of_header_lines); 0091 %calib team 0092 [gpsStartMin,alphabeta,alpha,beta,calline] = ctextread(filename,format_string,parameter,no_of_header_lines); 0093 % !!! Previous versions of this had alphabeta and alpha reversed and gave 0094 % wrong results - fixed 1/22/03 by stuver 0095 0096 0097 % 0098 % Search for the gps times of interest. 0099 % 0100 % WARNING: Heavily file format dependent! and NO ERROR checking included 0101 % 0102 0103 % Set maximum length to search 0104 gps_Vector_Length = size(gpsStartMin,1); 0105 0106 % Search gpsStartMin vector for gpsRange elements 0107 for gps_Start_row=1:gps_Vector_Length 0108 if (gpsStartMin(gps_Start_row) >= gpsOffsetSec) 0109 gps_Start_row = gps_Start_row - 1; % decrement so that first minute includes more than the first gps second 0110 break; 0111 end 0112 end 0113 0114 % Search gpsStartMin vector for band end element 0115 for gps_Stop_row=gps_Start_row:gps_Vector_Length 0116 if (gpsStartMin(gps_Stop_row) > gpsEndSec) 0117 if(gps_Stop_row > gps_Start_row) 0118 gps_Stop_row=gps_Stop_row - 1; % decrement so that last minute includes more than the last gps second 0119 end 0120 break; 0121 end 0122 end 0123 0124 % Return the resulting gpsinfo and alpha and alpha beta vectors 0125 0126 alpha = alpha(gps_Start_row:gps_Stop_row); 0127 beta = beta(gps_Start_row:gps_Stop_row); 0128 gpsStartMin = gpsStartMin(gps_Start_row:gps_Stop_row); 0129 0130 return