1. whatever method works best on your computer to do this type of thing. You can now load this file into your Workspace

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. whatever method works best on your computer to do this type of thing. You can now load this file into your Workspace

Post by answerhappygod »

1. whatever method works best on your computer to do this type of thing. You can now

load this file into your Workspace by typing load timeseries.txt in the Command Window

(as well as in the script you write). You should then have the variable timeseries in your

Workspace. This is some made up data (so don’t worry about units) that was sampled

at a frequency of 8192 samples/s. Write a MATLAB script that creates an array of time

values (with the same length as y) corresponding to the sampling frequency Fs (= 8192 samples/s). Plot the waveform as a function of time (in seconds). Label your axes for

this plot. Restrict the horizontal axis of your plot from t = 0 s to t = 1 s. Next, have your

script take the Fast Fourier Transform of y (using MATLAB’s built-in fft function) to

convert the signal to the frequency domain and then compute and plot the power

spectrum (the square of the amplitudes as a function of the frequency) as a second

figure. Label your axes. Similar to what I did in the notes, I only want you to look at the

positive frequencies in the power spectrum (i.e., the first half of the corresponding

frequency and power arrays). Using the sort function, find the values of the first five

dominant frequencies in the timeseries and print them to your pdf, each to an accuracy

of two decimal places. You may want to look back at the last few slides of the lecture

notes where I discuss MATLAB’s sort function. Don’t worry about the units on the

vertical axes for your two figures. Just label the vertical axis on figure 1, “y(t)” and the

vertical axis on figure 2, “Power”.

2. Now let’s use the Fast Fourier Transform to analyze some real data. First some

background information. Astronomers have been observing the Sun and recording data

about its sunspot activity since the invention of the telescope in 1609. The idea of

compiling this information originated with Rudolf Wolf in 1848. In order to do this, he

proposed a rule that combined the number and size of the sunspots into a single index,

now referred to as the Wolf number. Using archival records, astronomers have applied

this rule to quantify sunspot activity back to the year 1700. Today, the Wolf number is

measured by many astronomers and the worldwide distribution of the data is compiled

by the Solar Influences Data Center at the Royal Observatory of Belgium. Go to the

course shell on BbLearn. Inside the Homework folder (under this assignment), you

should find a “.txt” file named sunspot_year.txt. Copy this file into your Current Folder

(your “working directory”). You can now load this file into your Workspace by typing load

sunspot_year.txt in the Command Window (as well as in the script you write). You

should then have the variable sunspot_year in your Workspace. The first column of this

array are the years and the second column are the Wolf numbers for each year. As your

first figure for this problem, plot the Wolf number as a function of year as a solid black

line with black dots for markers. Label your axes, add a title, and turn on the grid. Note:

the Wolf number is a pure number (i.e., dimensionless). This timeseries looks

approximately cyclic (or periodic) in nature; the goal of this assignment is to determine

the approximate periodicity of this data. Next, have your script take the Fast Fourier

Transform of the timeseries (using MATLAB’s built-in fft function) to convert the signal to

the frequency domain and then compute and plot the power spectrum (the square of the

Fourier amplitudes as a function of the cycle frequency) as a second figure. Label your

axes, add a title, and turn on the grid. The first component of the Fourier Transform of

the timeseries is sometimes called the “DC component” (this terminology comes from applications of the fft in electrical engineering). This term is proportional to the average

of all the datapoints and is a time-independent term. Hence, it is not useful for us since

we are interested in the temporal variation of sunspot activity over the past few

centuries. So, you need to manually set this term to zero before proceeding. As far as

analyzing the data in the frequency domain, I only want you to look at the positive

frequencies in the power spectrum (i.e., the first half of the corresponding frequency and

power arrays). Make a third figure that plots the power spectrum as a function of the

cycle period. Label your axes, add a title, and turn on the grid. Find the period

corresponding to the maximum power (you can use MATLAB’s sort function or its max

function to do this). Print the approximate period of the sunspot cycle for the past 300

years (in years, to three significant figures) as a title for this plot.
Sunspot_year.txt

1700 5.0

1701 11.0

1702 16.0

1703 23.0

1704 36.0

1705 58.0

1706 29.0

1707 20.0

1708 10.0

1709 8.0

1710 3.0

1711 0.0

1712 0.0

1713 2.0

1714 11.0

1715 27.0

1716 47.0

1717 63.0

1718 60.0

1719 39.0

1720 28.0

1721 26.0

1722 22.0

1723 11.0

1724 21.0

1725 40.0

1726 78.0

1727 122.0

1728 103.0

1729 73.0

1730 47.0

1731 35.0

1732 11.0

1733 5.0

1734 16.0

1735 34.0

1736 70.0

1737 81.0

1738 111.0

1739 101.0

1740 73.0

1741 40.0

1742 20.0

1743 16.0

1744 5.0
1745 11.0

1746 22.0

1747 40.0

1748 60.0

1749 80.9

1750 83.4

1751 47.7

1752 47.8

1753 30.7

1754 12.2

1755 9.6

1756 10.2

1757 32.4

1758 47.6

1759 54.0

1760 62.9

1761 85.9

1762 61.2

1763 45.1

1764 36.4

1765 20.9

1766 11.4

1767 37.8

1768 69.8

1769 106.1

1770 100.8

1771 81.6

1772 66.5

1773 34.8

1774 30.6

1775 7.0

1776 19.8

1777 92.5

1778 154.4

1779 125.9

1780 84.8

1781 68.1

1782 38.5

1783 22.8

1784 10.2

1785 24.1

1786 82.9

1787 132.0

1788 130.9

1789 118.1

1790 89.9

1791 66.6

1792 60.0

1793 46.9

1794 41.0

1795 21.3
1796 16.0

1797 6.4

1798 4.1

1799 6.8

1800 14.5

1801 34.0

1802 45.0

1803 43.1

1804 47.5

1805 42.2

1806 28.1

1807 10.1

1808 8.1

1809 2.5

1810 0.0

1811 1.4

1812 5.0

1813 12.2

1814 13.9

1815 35.4

1816 45.8

1817 41.1

1818 30.1

1819 23.9

1820 15.6

1821 6.6

1822 4.0

1823 1.8

1824 8.5

1825 16.6

1826 36.3

1827 49.6

1828 64.2

1829 67.0

1830 70.9

1831 47.8

1832 27.5

1833 8.5

1834 13.2

1835 56.9

1836 121.5

1837 138.3

1838 103.2

1839 85.7

1840 64.6

1841 36.7

1842 24.2

1843 10.7

1844 15.0

1845 40.1

1846 61.5
1847 98.5

1848 124.7

1849 96.3

1850 66.6

1851 64.5

1852 54.1

1853 39.0

1854 20.6

1855 6.7

1856 4.3

1857 22.7

1858 54.8

1859 93.8

1860 95.8

1861 77.2

1862 59.1

1863 44.0

1864 47.0

1865 30.5

1866 16.3

1867 7.3

1868 37.6

1869 74.0

1870 139.0

1871 111.2

1872 101.6

1873 66.2

1874 44.7

1875 17.0

1876 11.3

1877 12.4

1878 3.4

1879 6.0

1880 32.3

1881 54.3

1882 59.7

1883 63.7

1884 63.5

1885 52.2

1886 25.4

1887 13.1

1888 6.8

1889 6.3

1890 7.1

1891 35.6

1892 73.0

1893 85.1

1894 78.0

1895 64.0

1896 41.8

1897 26.2
1898 26.7

1899 12.1

1900 9.5

1901 2.7

1902 5.0

1903 24.4

1904 42.0

1905 63.5

1906 53.8

1907 62.0

1908 48.5

1909 43.9

1910 18.6

1911 5.7

1912 3.6

1913 1.4

1914 9.6

1915 47.4

1916 57.1

1917 103.9

1918 80.6

1919 63.6

1920 37.6

1921 26.1

1922 14.2

1923 5.8

1924 16.7

1925 44.3

1926 63.9

1927 69.0

1928 77.8

1929 64.9

1930 35.7

1931 21.2

1932 11.1

1933 5.7

1934 8.7

1935 36.1

1936 79.7

1937 114.4

1938 109.6

1939 88.8

1940 67.8

1941 47.5

1942 30.6

1943 16.3

1944 9.6

1945 33.2

1946 92.6

1947 151.6

1948 136.3
1949 134.7

1950 83.9

1951 69.4

1952 31.5

1953 13.9

1954 4.4

1955 38.0

1956 141.7

1957 190.2

1958 184.8

1959 159.0

1960 112.3

1961 53.9

1962 37.5

1963 27.9

1964 10.2

1965 15.1

1966 47.0

1967 93.8

1968 105.9

1969 105.5

1970 104.5

1971 66.6

1972 68.9

1973 38.0

1974 34.5

1975 15.5

1976 12.6

1977 27.5

1978 92.5

1979 155.4

1980 154.6

1981 140.4

1982 115.9

1983 66.6

1984 45.9

1985 17.9

1986 13.4

1987 29.3
Timeseries.txt
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply