| Using the C++ Math Library | ![]() |
Deleting Elements from a Structure Array
There are three kinds of deletion operations you can perform on a structure array.
Deleting a Structure from the Array
To delete an entire structure from a structure array, assign the null array to that structure. For example, if you have a three-element array of image structures, you can delete the second image structure like this:
images(2) = empty();
images(2) = [] performs the same operation in MATLAB. The result is a two-element array of image structures.
Deleting a Field from All the Structures in an Array
To delete a field from all the structures in the array, use rmfield(). For example, you can remove the description field from an array of image structures, with this code:
images = rmfield(images, "description");
images = rmfield(images, 'description') performs the same operation in MATLAB.
Deleting an Element from an Array Contained by a Field
To delete an element from an array contained by a field, assign the null array to the indexing expression. For example, to remove the fifth column of the image in the third image structure:
images(3).field("image")(colon(),5) = empty();
images(3).image(:,5) = [] performs the same operation in MATLAB.
| Accessing the Contents of Structures Within Cells | Indexing Techniques | ![]() |