

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Aug 29, 2007
This assignment uses MATLAB to analyze historical weather data (1895-2006) from North Carolina, historical weather data (1946-2006) from Antarctica, and 2006 weather data from six U.S. cities. For this assignment, you have been provided with a ‘weather07.mat’ file that contains matrices with records of minimum and maximum temperatures (in Fahrenheit) and precipitation (rainfall measured in inches). Such weather data sets are typical examples of time series data. Using this data and MATLAB, you are to perform the following: With the historical data, ant_histannual and nc_histmonthly:
load weather whos Name Size Bytes Class ant_histannual 55x2 880 double array city1 365x4 11680 double array city2 365x4 11680 double array city3 365x4 11680 double array city4 365x4 11680 double array city5 365x4 11680 double array city6 365x4 11680 double array nc_histmonthly 112x13 11648 double array You may see other variables there if you didn’t start with a new MATLAB session. MATLAB commands You’ll probably use some of the following operations: Colon (:) and end for indexing, transpose (‘), mean(), sum(),arithmetic (+,-,,/,.,./), and cumsum(). Check your book or MATLAB’s doc for more information on these. Graphing commands bar() , plot(), and hist() are the main plotting methods. All plots should have meaningful titles and axes labels, using title(), xlabel(), ylabel(), and legend(). Vectors vs. Matrices You can use indexing with colon to pull particular columns out of a matrix and operate on them as vectors: e.g., maxtemp1 = city1(:,2); would pull out the maximum temperature column. You can also use brackets [] to put columns together into new matrices, such as a matrix of maximum temperatures. You can answer these questions just with vectors, but it involves less typing to use matrices because all cities can be operated on in parallel. Remember that MATLAB operates on columns of a data matrix for plotting and summing, so transpose can come in handy. Plots Here is the essential line from the help for plot : plot(X,Y) plots the columns of Y versus X if Y is a vector. If X is omitted, uses 1..length(Y). You can select colors/markers, etc. As an example, to plot city1 maximum temperatures in red, plot(city1(:,2), ‘r’), or if you created the vector maxtemp1 above you can type plot(maxtemp1, ‘r’). For details, see doc LineSpec. Plot erases the screen unless you have said hold on. Thus, to put more than one line on the same figure, either put them as columns in a matrix and plot once, or type hold on and plot several times. Type hold off to cancel a hold, or clf to clear the figure. Please use title, xlabel, and ylabel to add titles and axes labels to each plot. When appropriate, you can use legend(’name1’, ’name2’, …) to add a legend. E.g., to plot and label the maximum temperature for the six cities, make one matrix maxtemp and: plot(maxtemp) legend('city1','city2','city3','city4','city5','city6') title('Maximum Temperature') ylabel('Temperature (F)') xlabel('Day of the Year') Hand in on Blackboard You should make a Word document in which you paste a plot, and the MATLAB commands to generate the plot, for each of the questions. (In the Figure window you can select Edit>>Copy Figure, then paste into a Word document. Edit>>Copy is not the same as Edit>> Copy Figure.) A sample can be found under Assignment, which is where you will submit your assignment by midnight Sept 10. You can also use the publish capability, added in MATLAB 7, to write html or doc files directly; more on this in class. Data sources Southeast Regional Climate Center for NC data: National Climatic Data Center for city data, and British Antarctic Survey for Esperanza Station Data