Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- clc
- load midwest
- data = intermediate;
- uniqueZIPs = unique(data(:,2)); % get all the unique zip codes aka the final dataset
- % count = 0; % not sure what this is used for
- staralliance = {'JP','A3','AC','CA','AI','NZ','NH','OZ','OS','AV','SN','OU',...
- 'CM','MS','ET','BR','LO','LH','SK','ZH','SQ','SA','LX','TP','TG','TK','UA'};
- oneworld = {'US','AB','AA','BA','CX','AY','IB','JL','LA','MH','QF','QR','RJ'...
- 'S7','UL','JJ'};
- skyteam = {'SU','AR','AM','UX','AF','AZ','CI','MU','CZ','OK','DL','GA','KQ'...
- 'KL','KE','ME','SV','RO','VN','MF'};
- container = {staralliance,oneworld,skyteam};
- for i = 1:length(uniqueZIPs)
- %% Admin
- if mod(i,50) == 0
- disp(i)
- end
- filter = data(strcmp(data(:,2),uniqueZIPs{i}),:); % find in dataset where this unique zip is held
- totalpax = sum(cell2mat(filter(:,4)));
- %% ORD Pax
- AP_ORDpax = sum(cell2mat(filter(strcmp(filter(:,1),'ORD'),4)));
- AP_nonORDpax = sum(cell2mat(filter(~strcmp(filter(:,1),'ORD'),4)));
- %% DTW Pax
- AP_DTWpax = sum(cell2mat(filter(strcmp(filter(:,1),'DTW'),4)));
- AP_nonDTWpax = sum(cell2mat(filter(~strcmp(filter(:,1),'DTW'),4)));
- %% MSP Pax
- AP_MSPpax = sum(cell2mat(filter(strcmp(filter(:,1),'MSP'),4)));
- AP_nonMSPpax = sum(cell2mat(filter(~strcmp(filter(:,1),'MSP'),4)));
- %% AA Pax
- AL_AApax = sum(cell2mat(filter(strcmp(filter(:,3),'AA'),4)));
- AL_nonAApax = sum(cell2mat(filter(~strcmp(filter(:,3),'AA'),4)));
- %% DL Pax
- AL_DLpax = sum(cell2mat(filter(strcmp(filter(:,3),'DL'),4)));
- AL_nonDLpax = sum(cell2mat(filter(~strcmp(filter(:,3),'DL'),4)));
- %% UA Pax
- AL_UApax = sum(cell2mat(filter(strcmp(filter(:,3),'UA'),4)));
- AL_nonUApax = sum(cell2mat(filter(~strcmp(filter(:,3),'UA'),4)));
- %% US Pax
- AL_USpax = sum(cell2mat(filter(strcmp(filter(:,3),'US'),4)));
- AL_nonUSpax = sum(cell2mat(filter(~strcmp(filter(:,3),'US'),4)));
- %% ORD hubbing
- AP_AAUAPax = AL_UApax + AL_AApax;
- AP_xAAUAPax = totalpax - AP_AAUAPax;
- %% Hub or non-hub
- HUB = AP_DTWpax + AP_MSPpax + AP_ORDpax;
- nonhub = totalpax - HUB;
- %% alliance counts
- pax = 0;
- for N_alliances = 1:3
- alliance = container{N_alliances};
- for j = 1:length(alliance)
- filterpax = sum(cell2mat(filter(strcmp(filter(:,3),alliance{j}),4)));
- pax = filterpax + pax;
- end
- switch N_alliances
- case 1
- starpax = pax;
- nonstarpax = totalpax-starpax;
- case 2
- oneworldpax = pax;
- non1wpax = totalpax - oneworldpax;
- case 3
- skyteampax = pax;
- nonskypax = totalpax - skyteampax;
- end
- pax = 0;
- end
- %% Assignment
- uniqueZIPs{i,2} = AP_ORDpax;
- uniqueZIPs{i,3} = AP_nonORDpax;
- uniqueZIPs{i,4} = AP_DTWpax;
- uniqueZIPs{i,5} = AP_nonDTWpax;
- uniqueZIPs{i,6} = AP_MSPpax;
- uniqueZIPs{i,7} = AP_nonMSPpax;
- uniqueZIPs{i,8} = AL_AApax;
- uniqueZIPs{i,9} = AL_nonAApax;
- uniqueZIPs{i,10} = AL_DLpax;
- uniqueZIPs{i,11} = AL_nonDLpax;
- uniqueZIPs{i,12} = AL_UApax;
- uniqueZIPs{i,13} = AL_nonUApax;
- uniqueZIPs{i,14} = AL_USpax;
- uniqueZIPs{i,15} = AL_nonUSpax;
- uniqueZIPs{i,16} = AP_AAUAPax;
- uniqueZIPs{i,17} = AP_xAAUAPax;
- uniqueZIPs{i,18} = HUB;
- uniqueZIPs{i,19} = nonhub;
- % alliances
- uniqueZIPs{i,20} = starpax;
- uniqueZIPs{i,21} = nonstarpax;
- uniqueZIPs{i,22} = skyteampax;
- uniqueZIPs{i,23} = nonskypax;
- uniqueZIPs{i,24} = oneworldpax;
- uniqueZIPs{i,25} = non1wpax;
- uniqueZIPs{i,26} = totalpax;
- end
- T = cell2table(uniqueZIPs,'VariableNames',{'ZIP','ORD','notORD',...
- 'DTW','notDTW','MSP','notMSP','AApax','notAApax','DLpax','notDLpax',...
- 'UApax','notUApax','USpax','notUSpax',...
- 'ChicagoHubpax','NotChicagoHubpax','Hubpax','nothubpax',...
- 'StarAlliancepax','nonStarpax','skyteampax','nonskypax',...
- 'oneworldpax','non1wpax','totalpax'});
- writetable(T,'midwestpaxdiff.csv')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement