Why doesn't the subtract function work with 3D DiscreteGeometry in R2024b?
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Timothy
am 31 Dez. 2024
Bearbeitet: Walter Roberson
am 4 Jan. 2025
% Why doesn't the subtract function work with 3D DiscreteGeometry in R2024b?
model = femodel(); % Create a Finite element analysis model object
% Define dimensions of the rectangular plate (width, height, thickness)
plateWidth = 10;
plateHeight = 6;
plateThickness = 1;
% Create the rectangular plate
rectPlate = multicuboid(plateWidth, plateHeight, plateThickness);
% Define dimensions of the circular hole (radius, height)
holeRadius = 1;
holeHeight = plateThickness;
% Create the cylinder for the hole
cylinderHole = multicylinder(holeRadius, holeHeight);
% Subtract the cylinder from the plate
plateWithHole = subtract(rectPlate, cylinderHole);
% The error message follows...
'subtract' is used in the following examples:
-----------------------------------------------------------
I have also tried to use:
plateWithHole = addVoid(rectPlate, cylinderHole);
and I get the following error message.
Added cells must be located strictly inside a single cell of the original geometry.
In the error-generating case, the cylindrical void is the same thickness as the rectangular plate. If I make the cylindrical void ever so slightly shorter than the thickness of the plate, it works without error, but then I don't get a hole that goes completely through the plate.
-----------------------------------------------------------
What other Boolean functions will work with these DiscreteGeometry types that result in a hole going completely through the flat plate?


-----------------------------------------------------------
I’ve heard it said that subtract works in R2023, but I don't want to revert to that version.
Thank you,
Tim
3 Kommentare
Paul
am 1 Jan. 2025
If there was a "subtract" method for DiscreteGeometry objects in R2023 and there isn't now, perhaps that decision is discussed in the release notes for whatever version removed that method, perhaps pointing to an alternative method.
Don't know why the error message doesn't come with a link. But it looks like if "subtract" isn't found then Matlab does search through the documentation to find potential use-cases. I've never seen this type of message before (I've always seen "function not found" or something like that), perhaps it's a new feature.
DGM
am 2 Jan. 2025
Bearbeitet: DGM
am 2 Jan. 2025
I'm not sure, but the lack of links in the error message might just be a forum-only thing. I don't have the PDE toolbox, so I don't know.
Certainly, I found a lot of function() related docs links, but as much as those are relevant to function(), none are relevant to subtract().
Akzeptierte Antwort
Weitere Antworten (1)
Walter Roberson
am 1 Jan. 2025
In R2023a, the methods available for DiscreteGeometry are
addCell addVertex cellEdges extrude facesAttachedToEdges nearestFace scale
addFace addVoid cellFaces faceEdges nearestEdge rotate translate
You can subtract() certain kinds of Antenna Toolbox shapes; https://www.mathworks.com/matlabcentral/answers/2092471-creating-solid-geometry-with-pde or some RF Toolbox shapes
For subtracting geometries with the PDE toolbox, you use decsg
10 Kommentare
DGM
am 2 Jan. 2025
Bearbeitet: DGM
am 2 Jan. 2025
I'm the tangential simpleton here, but decsg() sounds terribly obtuse for object-level CSG, especially considering that I wouldn't have found out about it even after an hour's worth of dredging the docs for a toolbox I don't have. I'm going to re-suggest a comment I deleted earlier.
Is it possible or practical with your expected workflow to develop the composite geometry as a mesh and then convert it to a DiscreteGeometry object afterwards? I have seen that GPToolbox (FEX) has some CSG tools which I haven't tested, and there are any number of external tools that could do this. Even external tools can be exploited programmatically via system().
I don't have PDE toolbox and don't use DiscreteGeometry for anything, so I don't know if this is helpful. I'm just throwing this out there, since none of this seems like it's a satisfying resolution to the problem.
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!






