1 %This file is part of TEAP.
3 %TEAP is free software: you can redistribute it and/or modify
4 %it under the terms of the GNU General Public License as published by
5 %the Free Software Foundation, either version 3 of the License, or
6 %(at your option) any later version.
8 %TEAP is distributed in the hope that it will be useful,
9 %but WITHOUT ANY WARRANTY; without even the implied warranty of
10 %MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 %GNU General Public License
for more details.
13 %You should have received a copy of the GNU General Public License
14 %along with TEAP. If not, see <http://www.gnu.org/licenses/>.
17 %> @brief Checks that the signal given on the input is of the type nameWanted
18 %> This
function is mainly used by @b SSS_assert_type(Sig), with params @b Sig and @b SSS.
20 %> @attention NOTA BENE: in the
case that Signal is a BULK signal,
this function will
21 %>
return,
if it exists, the wanted signal, or fail
if it doesn
't.
23 %> @param Signal: The signal you want to make sure of the type (can be a BULK signal,
24 %> in that case, will take the component.
25 %> Bulk: if the input is a bulk than the bulk is also returned to keep a
26 %> backup of it. An empty vector is returned if the input is not a Bulk
27 %> @param nameWanted: the type the signal must be of (ex: 'GSR
').
29 %> @retval Signal: the signal. Can be the same as the input if single signal, or the
30 %> signal from the bulk if the input signal is a bulk one.
32 function [Signal, Bulk] = Signal__assert_type(Signal, nameWanted)
34 if(nargin ~= 2 || nargout > 2)
35 %If matlab was clever, they'd have implemented print_usage, like octave
36 error(
'Usage: [Signal, Bulk] = Signal__assert_type(Signal, nameWanted)')
39 if(~isfield(Signal, 'TEAP'))
40 error('The signal seems not to be a TEAP one.');
43 if(length(Signal) ~= 1)
44 error(['You seem to have given a bulk signal with multiple epochs. ' ...
45 'Could you please choose the epoch you want (eg: with Bulk(1))']);
48 %Initialize bulk to empty (in the case the input was not bulk)
51 %can either be a Bulk or a single signal
52 if(Signal.TEAP == 'S') %Single speed ^W Signal
54 elseif(Signal.TEAP == 'B') %Bulk signal
55 %We have to choose the signal that we want
57 Signal =
Bulk_get_signal(Signal, nameWanted); %Will fail if does not exist
59 error('The signal type is unknown. Should either be Signal or Bulk');
62 %And then, compare their name (redundant for 2nd case, but anyways :p)
64 if(~strcmp(name, nameWanted))
65 error(['Signal is of type: ' name '. Should be ' nameWanted])