from High Speed PIV and Hotwire post processing by Anurag
High Speed PIV and hotwire post processing routines

getswmax()
function maxsw = getswmax()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                                                                                                  %%
%%   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:                                                                                      %%
%%      getswmax.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                                                                                %%
%%                                                                                                  %%
%%                                                                                                  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%





global sw2D NX NY skip_files num_files num_datset

if(~any(sw2D))
   disp('ERROR: Swirl values not computed call, calc_sw() first before calling core_prco(). Aborting !!!');
   maxsw = 0;
   return;
end

found_swmax = 0;
tempsw  = sw2D;

totsets = num_datset * floor( (num_files + skip_files)/(skip_files+1));

while (found_swmax == 0)

   maxsw  = 0;
   maxfrm = 0;
   for m=1:totsets
      temp  = squeeze(tempsw(m,:,:));
      tmax  = max(max(temp));
      if(tmax > maxsw)
         maxfrm = m;
         maxsw  = tmax;
         [maxx maxy] = find(temp == maxsw);
      end
   end
   
   % Check if this point has at least a given number of adjoining points

   % establish the boundaries of the cell (maxx,maxy)
   xmin = maxx - 1;  if(xmin < 1 ); xmin = 1 ; end;
   xmax = maxx + 1;  if(xmax > NX); xmax = NX; end;

   ymin = maxy - 1;  if(ymin < 1 ); ymin = 1 ; end;
   ymax = maxy + 1;  if(ymax > NY); ymax = NY; end;
   
   
   [X Y]=find((tempsw(maxfrm,xmin:xmax,ymin:ymax) ~= 0));   % find out all the non-zero elements in above defined grid

   numpoints = size(X,1);
      
   if(numpoints < 4) % this is not a valid swmax, erase this point
      tempsw(maxfrm,xmin:xmax,ymin:ymax) = 0;
   else
      found_swmax = 1;
   end  
end
return

Contact us at files@mathworks.com