Last change
on this file 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
|
Rev | Line | |
---|
[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 | %
|
---|
| 9 | function [aout]=allequal(ain,aval)
|
---|
| 10 |
|
---|
| 11 | if ~nargin
|
---|
| 12 | help allequal
|
---|
| 13 | return
|
---|
| 14 | end
|
---|
| 15 |
|
---|
| 16 | aout=ain;
|
---|
| 17 |
|
---|
| 18 | if 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 |
|
---|
| 26 | elseif 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 |
|
---|
| 34 | elseif 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 |
|
---|
| 42 | elseif 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
|
---|
| 67 | end
|
---|
| 68 |
|
---|
| 69 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.