Least Squares and Real Data
Data Source: http://www.ncdc.noaa.gov/oa/climate/research/ushcn/
The data found above was cleaned and is found at the site below
disp('http://euclid.nmu.edu/~joshthom/ClimateData'); % Follow the link above, select a .mat file, download to your MATLAB directory disp('http://euclid.nmu.edu/~joshthom/ClimateData/ClimateStations.txt'); % The file Stations.txt indicate which cities correspond to which matrices.
Each matrix is roughly of size 118 by 14, and contains data recorded from a weather station in a particular city in the continental US.
% Each row corresponds to a year, starting with 1895. % Column 1 contains the year in which the temps were recorded. % Columns 2-13 contain MAX MONTHLY TEMPERATURES % January = 2, February = 3, ..., December = 13, etc. % Column 14 contains the average of the maximum monthly temperatures.
Load ONE matrix into MATLAB, and compute a "Least Squares Approximation" for each month. For example,
load(['MaxTempsStation_7.mat']); % The x-value are 1,2,3, ..., 117 representing the years 1895,1896,1897,...2012 % The y-values are entries of columns 2-13 from the matrix. % Proceed as in the examples in the text, producing a y-intercept and a slope. % On a single figure, plot a month of data along with the line of best fit you just computed. Do this for each month. % Create a 12-element vector whose entries are the least-squares-slopes for each month.
Repeat Assignment ONE for as many cities as you can and analyze the slopes found in each approximation.
% Is there a trend to the slopes?
% Load Data for i = 1:100 url_station = 'http://euclid.nmu.edu/~joshthom/ClimateData/MaxTempsStation_'; url_tail = '.mat'; n = num2str(i); url = [url_station,n,url_tail]; % a web address of .mat file for Station i a=urlwrite(url,'temp.mat'); % loads the .mat file into MATLABj load('temp.mat'); % this creates D with fields M (data matrix), Country (string) F = D.M; % the data matrix for Station i end
% - Mathematics: 3-5 % - Is the mathematics correct? Does your work make sense? % - MATLAB: 5-8 % - Are your figures labeled, colored or displayed nicely? Does your code work? Do you analyze many different data sets? % - Presentation 2-7 % - Is your presentation/project clear? Do you make a reasonable hypothesis? Do you understand what you're doing? % - Maximum Points Possible: 20