function [] = timeseries(frame1,frame2,yloc)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% %%
%% Copyright (C) 2005-2007 Anurag Singh %%
%% %%
%% This program/code snippet/file (hence forth refered as "library") %%
%% is free software; you can redistribute it and/or %%
%% modify it under the terms of the GNU Lesser General Public %%
%% License as published by the Free Software Foundation; either %%
%% version 2.1 of the License, or (at your option) any later version. %%
%% %%
%% This library is distributed in the hope that it will be useful, %%
%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %%
%% Lesser General Public License for more details. %%
%% %%
%% You should have received a copy of the GNU Lesser General Public %%
%% License along with this library; if not, write to the Free Software %%
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA %%
%% %%
%% FILENAME: %%
%% hwproc.m %%
%% %%
%% AUTHOR: %%
%% %%
%% Anurag Singh, %%
%% MS, 2007 %%
%% Aerospace Engineering & Mechanics %%
%% University of Minnesota - Twin Cities. %%
%% Minneapolis, MN 55455 (USA) %%
%% %%
%% (currently working at: Exa Corporation, Burlington, MA 01803) %%
%% %%
%% CONTACT/EMAIL: %%
%% %%
%% anurag@aem.umn.edu %%
%% anurag9@gmail.com %%
%% %%
%% SOURCE CONTROL INFORMATION: %%
%% None (since I was planning on putting it under source control since it has %%
%% reached the critical file system size. Would be a good thing to put it under %%
%% source control while making changes. %%
%% %%
%% DESCRIPTION: %%
%% %%
%% Need to add %%
%% %%
%% %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% USAGE:
%
% timeseries(frame1 frame2)
%
% Input Arguments:
% frame1 Frist frame index from which images are considered for time series computations
% frame2 Last frame index upto which images are considered for time series computations
% yloc Index of the ylocation where time series should be ploted
%
% Output: Time series plot of the mean stream wise velocity of the PIV frames.
% Following plots are generated:
%
% This function computes the time series of the mean velocity.
%
global u v vecimfreq flincr
if(nargin ~= 3)
disp (' ERROR: Insufficient arguments.');
help timeseries;
else
frame = frame2 - frame1 + 1;
imsiz = size(u,2);
uhw = zeros(1,frame*size(u,2));
for i=1:frame
uhw(((i-1)*imsiz + 1):(i*imsiz)) = u(frame1+i-1,:,yloc);
end
umean = zeros(1,frame*size(u,2));
umean(1) = uhw(1);
for i=2:size(uhw,2)
umean(i) = (umean(i-1)*(i-1) + uhw(i))/i;
end
ut = zeros(1,frame);
ut(1) = mean(u(frame1,:,30));
for i=2:frame
ut(i) = (ut(i-1)*(i-1) + mean(u(frame1+i-1,:,30)))/i;
end
figure;
%plot((1:1:size(umean,2))*2/capfreq,umean,'*');
plot((1:1:size(ut,2))*flincr/vecimfreq,ut,'*');
grid on
title('Time Series plot of Mean Velocity')
ylabel('Mean Velocity, m/s')
xlabel('Time, s')
end