setdiff
Set difference of fixed.Interval
objects
Syntax
Description
returns
a C
= setdiff(A, B
)fixed.Interval
object containing the values in fixed.Interval
object A
, but not in B
.
Examples
Get Set Difference of Two fixed.Interval
Objects
Create two fixed.Interval
objects. Use the setdiff
function to find the values that are in Interval
object interval1
but not in interval2
. In this example, interval1
contains all values between 0 and 1, but interval2
only contains values from 0 to 0.5, so the output Interval
object has an interval from 0.5 to 1.
interval1 = fixed.Interval(0,1); interval2 = fixed.Interval(0,0.5); intervaldiff = setdiff(interval1, interval2)
intervaldiff = (0.5000,1] 1x1 fixed.Interval with properties: LeftEnd: 0.5000 RightEnd: 1 IsLeftClosed: false IsRightClosed: true
Create an interval object that excludes zero
You can use the setdiff
function to create an
interval object based on another interval, while excluding zero.
Create an Interval
object that contains zero.
myInterval = fixed.Interval(-1,1);
To create an interval based on the Interval
object,
myInterval
, use the setdiff
function. Include
the constructor for a degenerate Interval
object containing only zero
as the second argument.
myInterval_nozero = setdiff(myInterval, {0});
myInterval_nozero = [-1,0) (0,1] 1x2 fixed.Interval with properties: LeftEnd RightEnd IsLeftClosed IsRightClosed
The output Interval
object, myInterval_nozero
,
contains two intervals, each with an open end point at zero. Therefore, the interval
contains all values between -1 and 1, except 0.
Input Arguments
A, B
— Input fixed.Interval
objects
fixed.Interval
object | array of fixed.Interval
objects
Input fixed.Interval
objects, specified as fixed.Interval
objects, or arrays of fixed.Interval
objects.
Output Arguments
C
— Set difference of fixed.Interval
objects
fixed.Interval
object | array of fixed.Interval
objects
Set difference of input fixed.Interval
objects, returned as a fixed.Interval
object or an array of fixed.Interval
objects.
The output Interval
object contains all values in first input,
A
, but not in B
.
Version History
Introduced in R2019b
See Also
fixed.Interval
| contains
| intersect
| overlaps
| union
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)