[797cbb]: comp / assert_classname.m  Maximize  Restore  History

Download this file

33 lines (27 with data), 783 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function classname = assert_classname(varargin)
% ASSERT_CLASSNAME
%
% Returns name of the "simplest" data type.
% Array of data types to be checked. Ordered from the "simplest" to the
% most "complex".
typesToTest = {'single','double'};
if nargin==0 || isempty(varargin)
classname = 'double';
return;
end
if ~all(cellfun(@(vEl) isnumeric(vEl),varargin))
error('%s: Parameters are not numeric types. ',upper(mfilename));
end
% Shortcut to double
if all(cellfun(@(vEl) isa(vEl,'double'),varargin))
classname = 'double';
return;
end
% Go trough all the types, halt if any of the inputs is of the specified
% type.
for ii=1:numel(typesToTest)
if any(cellfun(@(vEl) isa(vEl,typesToTest{ii}),varargin))
classname = typesToTest{ii};
return;
end
end

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks