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