function [FREQ,POWER] = Fourier_analysis()

clear; figure(1); clf; daqreset;

%%% parameters for the experiment
sample_rate = 48000;  
plot_duration = 0.5;   %% how frequent to plot
exp_duration = 30;   %% how long to collect data for

%%% Set up the parameters to acquire the data
AI = analoginput('nidaq','Brian');    
chan = addchannel(AI,0);
set(AI,'SampleRate',sample_rate);
set(AI,'SamplesPerTrigger',inf);
set(AI.channel(1),'InputRange',[-1 1]);

%%% allocate storage for all the transformed data
N = ceil(exp_duration/plot_duration);
%FREQ = zeros(sample_rate*plot_duration/2,N);
%POWER = zeros(sample_rate*plot_duration/2,N);

start(AI);
for i =1:N
    
    while AI.SamplesAvailable < sample_rate*plot_duration   %% wait until enough data
    end 
    [data time] = getdata(AI,(sample_rate*plot_duration));  %% get the data  
    
     subplot(2,1,1)
     plot(time,data);             
     xlabel('t (sec)'); ylabel('V');
     axis([min(time) max(time) -.1 .1])
     
     %subplot(2,1,2)    
     %[freq,p] = power_spec(time,data);
     %loglog(freq,p);        %% plot on lo-log scale
     %axis([ 10 10e3 1e-15 1])
     
     drawnow;
     
     %%% save all the transformed data, 
     %%%% uncomment this if you want to save the data for later. 
%     FREQ(:,i) = freq;
%     POWER(:,i) = p;
end


delete(AI);
clear AI;
end

function [freq,p] = power_spec(time,data)
%%%  you write this
end