Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(8 points) write and test a matlab function requiring reading from a file. See h

ID: 3822871 • Letter: #

Question

(8 points) write and test a matlab function requiring reading from a file. See here about the Mean Center of the US Population https:llen Wikipedia.org/wiki/Mean center of the United States population see http://www.cs.iit.edu/ccs104 labs at for the 2010 census population by state also including the latitude and longitude for each state. The record layout is: STNAME: state name POPULATION: 2010 Census population tabulated for the state LATITUDE: latitude coordinate for the center of population for the state LONGITUDE: longitude coordinate for the center of population for the statee Write a matlab script called populationMean to read the file and calculate the Mean Center of the US Population for the 50 states. Output the latitude and longitude of the mean center. Then use matlab code to add in these territories and see how the mean center moves: District of Columbia population 601723 latitude 38.91027 longitude--77.014468 Puerto Rico population 3725789 latitude 18.280422 longitude--66.346513 Look up the latitude and longitude of both answers and see which city is nearest to the mean center.

Explanation / Answer

//Following is the Matlab script for displaying lattitute and longitude of mean center

function [ avgw ] = readpatwts( path )
FID = fopen(path, 'r');
patha = textscan(FID, '%f');
a = patha{1};
b=patha{2};
c=patha{3};
if FID ~= -1
fprintf('FILE OPENED SUCCESSFULLY! ');
avg =sum(a)./4;
avgw = fprintf('THE AVG WEIGHT IS: %s. ',avg);
for i=0:a.length()
if a[i]==avg
print("Lattitute:",b(i))
print("Longitute:",c(i))
end
end
  
  
else
fprintf('ERROR CANNOT OPEN FILE TO READ! ');
end
if fclose(FID) == 0;
fprintf('FILE CLOSED SUCCESSFULLY! ');
else
fprintf('FILE NOT CLOSED SUCCESSFULLY! ');
end
end

readpatwts("./input.txt")