% Matlab Assignment No. 8:
% 
%  - Download the one-dimensional signal file, signal.raw, located in this
%    directory. This file contains 16-bit integer samples of a signal
%    sampled at 8 kHz. Write a matlab program that allows the user to specify 
%    the center time and window duration in seconds as arguments.
%    Plot the corresponding signal.
% 
%    For example, if the user specifies a center time of 0.5 secs, and
%    a window duration of 0.03 secs, you should plot the portion of the
%    file that starts at sample number:
% 
%        start_sample = (0.5 - 0.03/2) * 8000 = 3880;
% 
%    and ends at:
% 
%        end_sample = start_sample + 0.03*8000 - 1 = 4119;
% 
%  - In addition to plotting the waveform, plot the magnitude spectrum
%    in dB (as in problem 7) for the corresponding signal.
% 
%  - Demonstrate what happens to the spectrum as you increase the window
%    duration of the signal.
% 
%  - Demonstrate the different types of spectra you can find in this file
%    (look at different parts of the waveform). Listen to the data and explain
%    why the spectra differ.
% 
% This assignment is due before the beginning of the final exam.
%

global my_signal;


filename='signal.raw';
fid = fopen(filename,'r');
if fid < 0,
	disp('error opening file signal.raw');
else
	fprintf('Reading %s\n',filename);
	my_signal = fread(fid,inf,'int16');
end

fclose(fid);


