[876] | 1 | %'diff_vel': calculate the difference of two input velocity fields.
|
---|
[870] | 2 | %
|
---|
[876] | 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 |
|
---|
[870] | 8 | %-----------------------------------------------------------------------
|
---|
[876] | 9 | % function SubData=diff_vel(Field,XmlData,Field_1)
|
---|
[870] | 10 | %
|
---|
| 11 | % OUPUT:
|
---|
| 12 | % SubData: structure representing the resulting field
|
---|
| 13 | %
|
---|
| 14 | % INPUT:
|
---|
| 15 | % Field: matlab structure representing the first field
|
---|
[876] | 16 | % XmlData: not used, needed for consistency with the call of transform fct.
|
---|
[870] | 17 | % Field_1:matlab structure representing the second field
|
---|
| 18 |
|
---|
| 19 | %=======================================================================
|
---|
[908] | 20 | % Copyright 2008-2015, LEGI UMR 5519 / CNRS UJF G-INP, Grenoble, France
|
---|
[870] | 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 |
|
---|
[883] | 37 | function Field=diff_vel(Field,XmlData,Field_1)
|
---|
[870] | 38 |
|
---|
[883] | 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
|
---|
[870] | 61 | if exist('Field_1','var')
|
---|
| 62 | F.U=scatteredInterpolant(Field_1.X,Field_1.Y,Field_1.U,'linear');
|
---|
[883] | 63 | Field.U=Field.U-Factor*F.U(Field.X,Field.Y);%substract the interpolated ref to U
|
---|
[870] | 64 | F.V=scatteredInterpolant(Field_1.X,Field_1.Y,Field_1.V,'linear');
|
---|
[883] | 65 | Field.V=Field.V-Factor*F.V(Field.X,Field.Y);%substract the interpolated ref to V
|
---|
[870] | 66 | end
|
---|
| 67 | |
---|