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
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
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
IsRightClosedThe 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
Input fixed.Interval objects, specified as fixed.Interval
objects, or arrays of fixed.Interval objects.
Output Arguments
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.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- 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)