function out = change_percent(data,regionid,percent)
% out = change_percent(data,regionid,percent)
% Purpose: changes the percent of total immigration that comes to a region;
% Input:
%     data = either a population or immigrant vector
%     regionid = a number from 1-9 representing the region
%     percent = a number from 0-1 representing the new proportion
%         of immigrants coming to the region
% Output:
%     A [36x1] population vector, with females 0-85+ 
%         and then males 0-85+;
% REGION IDS:
% 1 = Tahoe
% 2 = LA
% 3 = San Diego
% 4 = Fresno
% 5 = SF
% 6 = Sacramento
% 7 = Shasta
% 8 = Oregon
% 9 = Rest of US
pop = zeros(36,9);
for i = 1:9
    pop(:,i) = data(i:9:315+i);
end;
colsum = sum(pop);
total = sum(sum(pop));
cur_percent = sum(pop)/total;
cur_remainder = 1-cur_percent(regionid);
remainder = 1-percent;
new_percent = zeros(1,9);
new_percent = (cur_percent./cur_remainder)*remainder;
new_percent(regionid) = percent;
newpop = zeros(36,9);
for i = 1:9
    newpop(:,i) = (pop(:,i)*(new_percent(i)/cur_percent(i)));
end;
out = zeros(324,1);
for i = 1:9
    out(i:9:315+i) = newpop(:,i);
end;