source: issm/trunk/src/m/array/allequal.m@ 23189

Last change on this file since 23189 was 23189, checked in by Mathieu Morlighem, 7 years ago

merged trunk-jpl and trunk for revision 23187

  • Property svn:executable set to *
File size: 1.4 KB
RevLine 
[33]1% function to return an empty array if all array elements are
[7397]2% equal to the given value, which may also be empty but not nan.
[33]3%
[7397]4% (note that by definition, nan is not equal to nan. this could
5% be changed by using isequalwithequalnans.)
6%
[33]7% function [aout]=allequal(ain,aval)
8%
9function [aout]=allequal(ain,aval)
10
11if ~nargin
12 help allequal
13 return
14end
15
16aout=ain;
17
18if islogical(ain) && islogical(aval)
19 for i=1:numel(ain)
[7397]20 if ~isequal(ain(i),aval)
[33]21 return
22 end
23 end
24 aout=logical([]);
25
26elseif isnumeric(ain) && isnumeric(aval)
27 for i=1:numel(ain)
[7397]28 if ~isequal(ain(i),aval)
[33]29 return
30 end
31 end
32 aout=[];
33
34elseif ischar(ain) && ischar(aval)
35 for i=1:size(ain,1)
36 if ~strcmp(ain(i,:),aval)
37 return
38 end
39 end
40 aout='';
41
42elseif iscell(ain)
43 if islogical(aval)
44 for i=1:numel(ain)
[7397]45 if ~islogical(ain{i}) || ~isequal(ain{i},aval)
[33]46 return
47 end
48 end
49 aout={};
50
51 elseif isnumeric(aval)
52 for i=1:numel(ain)
[7397]53 if ~isnumeric(ain{i}) || ~isequal(ain{i},aval)
[33]54 return
55 end
56 end
57 aout={};
58
59 elseif ischar(aval)
60 for i=1:size(ain,1)
61 if ~ischar(ain{i}) || ~strcmp(ain{i},aval)
62 return
63 end
64 end
65 aout={};
66 end
67end
68
69end
Note: See TracBrowser for help on using the repository browser.