source: trunk/src/transform_field/diff_vel.m @ 977

Last change on this file since 977 was 977, checked in by g7moreau, 4 years ago
  • Update Copyright 2008-2017 notice
File size: 2.8 KB
Line 
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 2008-2017, LEGI UMR 5519 / CNRS UGA G-INP, Grenoble, France
21%   http://www.legi.grenoble-inp.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
37function Field=diff_vel(Field,XmlData,Field_1)
38
39%% request input parameters
40if 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
56end
57Factor=1;
58if isfield(XmlData,'TransformInput') && isfield(XmlData.TransformInput,'Factor')
59Factor=XmlData.TransformInput.Factor;
60end
61if exist('Field_1','var')
62          F.U=scatteredInterpolant(Field_1.X,Field_1.Y,Field_1.U,'linear');
63         Field.U=Field.U-Factor*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.V-Factor*F.V(Field.X,Field.Y);%substract the interpolated ref to V
66end
67 
Note: See TracBrowser for help on using the repository browser.