readTempFile - % create empty daily average air temperature...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
function tp = readTempFile(fileName) % H1 line as needed % readTempFile reads an hourly air temperature file in Fahrenheit, the name % of which is sent to the function, and converts the data to daily % averages, converted to celsius. % % calling sequence: tempData = readTempFile(hourlyTemperatureFileName) % % Record of coding % 15 August 2005, original coding, Hugh Mongus % % Variable dictionary % hrTemps: array of hourly air temperatures, F or C % tp: array daily average air temperatures, C % days: number of days in the data set % d: looping variable % temps: summing variable for one day of data % read fahrenheit air temperature values from file and convert to celsius hrTemps = textread(fileName); hrTemps = (hrTemps - 32)/1.8; % convert F to C
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % create empty daily average air temperature array tp = [ ]; % start with empty array % check to be sure the file has full days of data, abort if not true if (mod(length(hrTemps), 24) ~= 0) disp('Data file does not contain a full number of days!'); else % calculate the number of days in the data set days = length(hrTemps)/24; % average 24 hourly values for each day for d = 1:days temps(d) = 0; % initialize summing variable to zero for h = 1:24 % sum 24 hours of data temps(d) = temps(d) + hrTemps(24*(d-1) + h); end % for h = 1:24 tp = [tp temps(d)/24]; % concatenate day averages to tp, by element end % for d = 1:days end % if (mod(length(hrTemps), 24) ~= 0) end % function readTempFile...
View Full Document

This note was uploaded on 09/28/2009 for the course BEE 1510 taught by Professor Staff during the Fall '05 term at Cornell University (Engineering School).

Ask a homework question - tutors are online