%This is an m-file to illustrate how to do a prblem similar to chapter 3,
%exercise 5. 

f=@(t) sin(pi*t)+ 0.3*t.*sin(10*pi*t) % Define function
t=(0:255)*(4/256); % Time array -- (0,1/64,2/64,...,255/64)
y=f(t); % f evaluated at times in array t.
yhat=fftshift(fft(y)); % Calculate the fft of y; 0 is frequency "center."
delta_omega=2*pi/4; % Frequency increment.
omega=(-128:127)*delta_omega; % Array containing frequencies.
plot(omega,abs(yhat)) % Plot omega vs. abs(yhat)
% Visually find the frequency that has the largest amplitude. Probably the
% easiest way to do that is to use the "data cursor" from the list of
% tools. Put the cursor over the pear and click. The freuqncy you get is in
% radians/sec. To get the nataural frequency in Hz, divide by 2*pi.