%% apfile.m loads in the required 3-hourly Kp_Ap data
%% text files and converts the Ap values into binary 
%% MATLAB files.
%% It breaks the data into seperate year, month, day
%% and daily AP vectors, as well as a matrix with the
%% 3-hourly AP values for each day in each column.
%%

clear

years=input('Starting File Year? ');
yearf=input('Finishing File Year? ');

nop=yearf-years+1;                      %number of files to be converted
yeari=years;                            %year index

for i=1:nop
 eval(['load a',int2str(yeari),'.txt -ascii'])
 eval(['data=a',int2str(yeari),';'])
 yrv=data(:,1);
 mnv=data(:,2);
 dyv=data(:,3);
 apv=data(:,12);
 ap3h=data(:,4:11);
 eval(['save a',int2str(yeari),' yrv mnv dyv apv ap3h'])
 eval(['clear a',int2str(yeari)])
 yeari=yeari+1;  
end 