THE POWER SPECTRUM Applied Numerical Methods with MATLAB fo

EXAMPLE 16.4 Computing the Power Spectrum with MATLAB Problem Statement. Compute the power spectrum for the simple sinusoid for which the DFT was computed in Example 16.3. Solution. The following script can be developed to compute the power spectrum: compute the DFT clc;clf n=8; dt=0.02; fs=1dt;tspan=0:n-1fs; y=5+cos2pi12.5tspan+sin2pi18.75tspan; Y=fftyn; f = 0:n-1fsn; Y1=[];f1=[]; compute and display the power spectrum nyquist=fs2; f = 1:n2n2nyquist; Pyy = absY1:n2.2; stemf,Pyy,linewidth,2,MarkerFaceColor,blue titlePower spectrum xlabelFrequency Hz;ylim[0 0.3] As indicated, the first section merely computes the DFT with the pertinent statements from Example 16.3. The second section then computes and displays the power spectrum. As in Fig. 16.12, the resulting graph indicates that peaks occur at both 12.5 and 18.75 Hz as expected. 6 8 26 10 12 14 16 18 20 22 24 0.05 0.1 0.15 0.2 0.25 Power spectrum Frequency Hz FIGURE 16.12 Power spectrum for a simple sinusoidal function with frequencies of 12.5 and 18.75 Hz. 16.7 CASE STUDY 401

16.7 CASE STUDY SUNSPOTS

Background. In 1848, Johann Rudolph Wolf devised a method for quantifying solar activity by counting the number of individual spots and groups of spots on the sun’s sur- face. He computed a quantity, now called a Wolf sunspot number, by adding 10 times the number of groups plus the total count of individual spots. As in Fig. 16.13, the data set for the sunspot number extends back to 1700. On the basis of the early historical records, Wolf determined the cycle’s length to be 11.1 years. Use a Fourier analysis to confirm this result by applying an FFT to the data. Solution. The data for year and sunspot number are contained in a MATLAB file, sunspot.dat. The following statements load the file and assign the year and number in- formation to vectors of the same name: load sunspot.dat year=sunspot:,1;number=sunspot:,2; Before applying the Fourier analysis, it is noted that the data seem to exhibit an upward lin- ear trend Fig. 16.13. MATLAB can be used to remove this trend: n=lengthnumber; a=polyfityear,number,1; lineartrend=polyvala,year; ft=number-lineartrend; Next, the fft function is employed to generate the DFT F=fftft; The power spectrum can then be computed and plotted fs=1; f=0:n2fsn; pow=absF1:n2+1.2; FIGURE 16.13 Plot of Wolf sunspot number versus year. The dashed line indicates a mild, upward linear trend. 1700 2000 1750 1800 1850 1900 1950 50 100 150 200 plotf,pow xlabelFrequency cyclesyear; ylabelPower titlePower versus frequency The result, as shown in Fig. 16.14, indicates a peak at a frequency of about 0.0915 Hz. This corresponds to a period of 10.0915 = 10.93 years. Thus, the Fourier analysis is consistent with Wolf’s estimate of 11 years.

16.7 CASE STUDY continued

FIGURE 16.14 Power spectrum for Wolf sunspot number versus year. 0.05 0.5 0.1 0.15 0.2 0.25 0.3 0.35 0.4 0.45 2000 3000 4000 5000 Power spectrum Power Cyclesyear 1000 PROBLEMS

16.1 The pH in a reactor varies sinusoidally over the course

of a day. Use least-squares regression to fit Eq. 16.11 to the following data. Use your fit to determine the mean, amplitude, and time of maximum pH. Note that the period is 24 hr Time, hr 2 4 5 7 9 pH 7.6 7.2 7 6.5 7.5 7.2 Time, hr 12 15 20 22 24 pH 8.9 9.1 8.9 7.9 7

16.2 The solar radiation for Tucson, Arizona, has been tab-

ulated as Time, mo J F M A M J Radiation, Wm 2 144 188 245 311 351 359 Time, mo J A S O N D Radiation, Wm 2 308 287 260 211 159 131 Assuming each month is 30 days long, fit a sinusoid to these data. Use the resulting equation to predict the radiation in mid-August.