CenterPop - znew = zbar/r; z % Find latitude and longitude...

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

View Full Document Right Arrow Icon
% Script CenterPop.m % Eric Young CS 100M % % Call function Zipcode % [namevec popvec latvec longvec] = Zipcode; [ x = []; y = []; z = []; z for i = 1:length(longvec) f pheta = latvec(i); phi = longvec(1); x = [x;cos(pheta*(pi/180))*cos(phi*(pi/180))]; y = [y;-1*cos(pheta*(pi/180))*sin(phi*(pi/180))]; z = [z;sin(pheta*(pi/180))]; z end e %Find Cartesian center of population: % % Total U.S. Population. . % P = sum(popvec); P sum1 = 0; sum2 = 0; sum3 = 0; s for j=1:length(x) sum1 = sum1 + x(j)*popvec(j); sum2 = sum2 + y(j)*popvec(j); sum3 = sum3 + z(j)*popvec(j); end e % Cartesian center of pop is (xbar,ybar,zbar) % xbar = sum1/P; ybar = sum2/P; zbar = sum3/P; x % Find spherical center of population % r = sqrt((xbar)^2+(ybar)^2+(zbar)^2); r % Spherical center of pop. is (xbar/r,ybar/r,zbar/r): % xnew = xbar/r; ynew = ybar/r;
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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: znew = zbar/r; z % Find latitude and longitude of spherical centroid on the surface of the % earth: % pheta = asin(znew); phi = acos((xnew)/(cos(pheta))); pheta = pheta*(180/pi); phi = phi*(180/pi); p % Display latitude and longitude: % disp('The spherical centroid of the USA population:') d disp(sprintf('Latitude: %5.10f N',pheta)) disp(sprintf('Longitude: %5.10f W',phi)) d % PLEASE see changePop file for explanation of fcn and how it was used. % There is little change in the centroid position caused by adding % one more person to ithaca NY 14850. The N latitude does goes from % 37.6986002106 to 37.6986002275;the very % tiny increase makes sense since ithaca is north of centroid point. The % distance is less than an inch. %...
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 / 2

CenterPop - znew = zbar/r; z % Find latitude and longitude...

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

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