% IAP 2007 Introduction to MATLAB: Programming Practice % Instructor: Violeta Ivanova, violeta@mit.edu % Exercise Two: Writing a Program % Write a MATLAB program to compute the Sun's zenith and azimuth in Boston. % Boston's is located at Latitude 42.3580N; Longitude 71.06W; Altitude 49 ft. % Use functions UNITS and SUN_POSITION from MATLAB Central. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function x = SunBoston(year, month, day, hour, min, sec) % A. COMPUTE TIME % Use structure TIME as described in help text for function SUN_POSITION. nowBoston.year = year; nowBoston.month = month; nowBoston.day = day; nowBoston.hour = hour; nowBoston.min = min; nowBoston.sec = sec; nowBoston.UTC = -5 % B. COMPUTE ALTITUDE % Use function UNITS to convert 'ft' to 'm'. altitude = units(49, 'ft', 'm'); % C. COMPUTE LOCATION % Use structure LOCATION as described in help text for function SUN_POSITION. Boston.latitude = 42.358; Boston.longitude = -71.06; Boston.altitude = altitude % D. COMPUTE SUN POSITION IN BOSTON % Use function SUN_POSITION. Sun_Boston = sun_position(nowBoston, Boston)