function [year, day] = snowfall % snowfall -- First snowfall, Logan Airport, Boston, MA. % [year, day] = snowfall (no argument) returns or displays % he year and the day of then first trace of snow after % September 30, beginning with 1891. % Source: Boston Sunday Globe, December 26, 1999, % page B8, based on National Weather Service data. % The values were taken from the graph using a % Gerber scale. % yd = snowfall (no argument) returns the snowfall data % as a two-column array [year day]. % Copyright (C) 1999 Dr. Charles R. Denham, ZYDECO. % All Rights Reserved. % Disclosure without explicit written consent from the % copyright owner does not constitute publication. % Version of 29-Dec-1999 09:15:01. % Updated 13-Jan-2000 09:19:13. data = [ % Day and year. 23 1891 35 1892 46 1893 37 1894 52 1895 44 1896 43 1897 56 1898 3 1899 40 1900 64 1901 29 1902 63 1903 27 1904 44 1905 52 1906 62 1907 44 1908 26 1909 44 1910 33 1911 43 1912 14 1913 27 1914 46 1915 43 1916 24 1917 57 1918 36 1919 46 1920 38 1921 55 1922 39 1923 48 1924 10 1925 36 1926 58 1927 27 1928 52 1929 48 1930 37 1931 50 1932 37 1933 13 1934 46 1935 47 1936 50 1937 47 1938 40 1939 21 1940 24 1941 34 1942 42 1943 37 1944 35 1945 46 1946 43 1947 60 1948 38 1949 52 1950 32 1951 30 1952 37 1953 56 1954 47 1955 42 1956 26 1957 60 1958 39 1959 24 1960 15 1961 25 1962 31 1963 21 1964 32 1965 63 1966 38 1967 41 1968 22 1969 17 1970 41 1971 15 1972 77 1973 62 1974 31 1975 41 1976 44 1977 52 1978 10 1979 41 1980 58 1981 45 1982 45 1983 44 1984 47 1985 42 1986 41 1987 8 1988 49 1989 39 1990 39 1991 39 1992 55 1993 54 1994 44 1995 58 1996 45 1997 83 1998 105 1999 % And still counting. ]; yr = data(:, 2); da = data(:, 1); if nargout > 0 year = yr; day = da; if nargout < 2 year = [yr da]; else year = yr; day = da; end else help(mfilename) x = yr; y = da; xi = yr; p1 = polyfit(x, y, 1); p2 = polyfit(x, y, 2); p3 = polyfit(x, y, 3); y1 = polyval(p1, xi); y2 = polyval(p2, xi); y3 = polyval(p3, xi); subplot(2, 1, 1) if exist('hilbert', 'file') == 2 h = feval('hilbert', y - mean(y)); hi = abs(h) + mean(y); lo = -abs(h) + mean(y); plot(x, y, '-bo',x(end), y(end), 'r*', x, hi, 'k-', x, lo, 'k-') else plot(x, y, '-bo',x(end), y(end), 'r*') end axis tight title('First Trace of Snow at Logan Airport') xlabel('Year') ylabel('Days After September 30') subplot(2, 1, 2) plot(x, y, 'o',x(end), y(end), 'r*', xi, y1, xi, y2, xi, y3) axis tight xlabel('Year') ylabel('Days After September 30') zoomsafe all findpt figure(gcf) legend('data', '1999', '1st order', '2nd', '3rd', 0) set(gcf, 'Name', 'SnowFall', 'ResizeFcn', 'legend') end