ChangePop - n Function changePop generates a NEW vector called newPop which is the exact same as the pop input vector except with the population

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
function newPop = changePop(pop,name,zips,delta) f % newPop is the adjusted population data % pop is the n-vector of population data % zips is a p-by-7 char matrix containing the names of the zip areas where % the pop data are to be changed. p<=n % delta is the adjustments to the population data % delta(k) is the change to zip area zips(k) % name is n-by-7 matrix of all zip area names % [rows cols] = size(zips); [ % iterate through each possible zipcode in input zips vector % for k =1:rows % iterate through every zipcode name in namevec for f = 1:length(name) % a ha! - the zip codes match if name(f,:)==zips(k,:) % then, increase the corresponding population in the vector by % delta pop(f) = pop(f) + delta(k); end end end e newPop = pop; % newPop now houses the updated population vector
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: n % Function changePop generates a NEW vector called newPop which is the % exact same as the pop input vector except with the population changes % made. % % FOR EXAMPLE: typing in [name,pop,lat,long] = Zipcode;zips = % ['NY14850'];delta = [500];newPop = changePop(pop,name,zips,delta); in the % command window will generate a vector newPop which will increase the old % population value for NY14850 by 500 people. This function can be used % to generate newPop, the adjusted population data, which can then in turn % be used to find out how the centroid point changes if the population of % Ithaca is increased by ONE person.(See Script CenterPop for results). % % %...
View Full Document

This note was uploaded on 09/12/2009 for the course CS 100 taught by Professor Fan/vanloan during the Fall '07 term at Cornell University (Engineering School).

Page1 / 3

ChangePop - n Function changePop generates a NEW vector called newPop which is the exact same as the pop input vector except with the population

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online