Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DCT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
graintracking
DCT
Commits
58f9f4dd
Commit
58f9f4dd
authored
7 years ago
by
Nicola Vigano
Browse files
Options
Downloads
Patches
Plain Diff
Improved "between" function's behavior
Signed-off-by:
Nicola Vigano
<
nicola.vigano@esrf.fr
>
parent
bd4f2884
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
zUtil_Maths/between.m
+14
-25
14 additions, 25 deletions
zUtil_Maths/between.m
with
14 additions
and
25 deletions
zUtil_Maths/between.m
+
14
−
25
View file @
58f9f4dd
function
answer
=
between
(
arg
,
a
,
b
)
function
answer
=
between
(
arg
,
a
,
b
)
% FUNCTION BETWEEN logical operation
% function answer=between(arg, a, b)
%
% returns true if arg <= b && arg >= a
% arg may either be a scalar or a matrix of same size like a and b
if
size
(
a
)
~=
size
(
b
)
mexc
=
MException
(
'BETWEEN:wrong_input'
,
...
'input arguments need to be same size. Exiting...'
);
throw
(
mexc
);
end
if
~
isscalar
(
arg
)
&&
any
(
size
(
a
)
~=
size
(
arg
))
mexc
=
MException
(
'BETWEEN:wrong_input'
,
...
'arg needs to be either a scalar or a matrix of same size as a and b! Exiting...'
);
throw
(
mexc
);
end
answer
=
false
(
size
(
a
));
if
(
~
all
(
size
(
a
)
==
size
(
b
)
|
size
(
a
)
==
1
|
size
(
b
)
==
1
))
error
(
'BETWEEN:wrong_input'
,
...
'input arguments need to be same size'
);
end
if
(
size
(
arg
)
==
size
(
a
))
for
ii
=
1
:
numel
(
a
)
if
(
arg
(
ii
)
<=
b
(
ii
))
&&
(
arg
(
ii
)
>=
a
(
ii
))
answer
(
ii
)
=
true
;
end
if
(
~
isscalar
(
arg
)
&&
~
all
(
size
(
a
)
==
size
(
arg
)
|
size
(
a
)
==
1
))
error
(
'BETWEEN:wrong_input'
,
...
'arg needs to be either a scalar or a matrix of same size as a and b!'
);
end
else
for
ii
=
1
:
numel
(
a
)
if
(
arg
<=
b
(
ii
))
&
&
(
arg
>=
a
(
ii
))
answer
(
ii
)
=
true
;
end
if
(
numel
(
arg
)
==
1
||
all
(
size
(
arg
)
==
size
(
a
)
))
answer
=
arg
<=
b
&
arg
>=
a
;
else
answer
=
bsxfun
(
@
and
,
bsxfun
(
@
le
,
arg
,
b
),
bsxfun
(
@
ge
,
arg
,
a
));
end
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment