1  %'diff_vel': calculate the difference of two input velocity fields.


2  %


3  % the second velocity field is linearly interpolated


4  % (after elimination of the vectors marked with an error flag) to the positions of


5  % the first one before subtraction. The ancilary data of the first field


6  % are preserved while those of the second one are lost.


7 


8  %


9  % function SubData=diff_vel(Field,XmlData,Field_1)


10  %


11  % OUPUT:


12  % SubData: structure representing the resulting field


13  %


14  % INPUT:


15  % Field: matlab structure representing the first field


16  % XmlData: not used, needed for consistency with the call of transform fct.


17  % Field_1:matlab structure representing the second field


18 


19  %=======================================================================


20  % Copyright 20082024, LEGI UMR 5519 / CNRS UGA GINP, Grenoble, France


21  % http://www.legi.grenobleinp.fr


22  % Joel.Sommeria  Joel.Sommeria (A) legi.cnrs.fr


23  %


24  % This file is part of the toolbox UVMAT.


25  %


26  % UVMAT is free software; you can redistribute it and/or modify


27  % it under the terms of the GNU General Public License as published


28  % by the Free Software Foundation; either version 2 of the license,


29  % or (at your option) any later version.


30  %


31  % UVMAT is distributed in the hope that it will be useful,


32  % but WITHOUT ANY WARRANTY; without even the implied warranty of


33  % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the


34  % GNU General Public License (see LICENSE.txt) for more details.


35  %=======================================================================


36 


37  function Field=diff_vel(Field,XmlData,Field_1)


38 


39  %% request input parameters


40  if isfield(Field,'Action') && isfield(Field.Action,'RUN') && isequal(Field.Action.RUN,0)


41 


42  %default input:


43  def={'1'};% multiplicative factor for the second velocity field


44 


45  if isfield(XmlData,'TransformInput')% if parameters have been memorised


46  if isfield(XmlData.TransformInput,'Factor')


47  def{1}=num2str(XmlData.TransformInput.Factor);


48  end


49  end


50  num_lines= 1;%numel(prompt);


51  % open the dialog fig


52  prompt='enter scale factor for the second field';


53  answer = inputdlg(prompt,'',num_lines,def);


54  Field.TransformInput.Factor=str2num(answer{1});


55  return


56  end


57  Factor=1;


58  if isfield(XmlData,'TransformInput') && isfield(XmlData.TransformInput,'Factor')


59  Factor=XmlData.TransformInput.Factor;


60  end


61  if exist('Field_1','var')


62  F.U=scatteredInterpolant(Field_1.X,Field_1.Y,Field_1.U,'linear');


63  Field.U=Field.UFactor*F.U(Field.X,Field.Y);%substract the interpolated ref to U


64  F.V=scatteredInterpolant(Field_1.X,Field_1.Y,Field_1.V,'linear');


65  Field.V=Field.VFactor*F.V(Field.X,Field.Y);%substract the interpolated ref to V


66  end


67  
