Warm tip: This article is reproduced from stackoverflow.com, please click
matlab matlab-struct

Matlab Struct Manipulation

发布于 2020-04-07 10:24:32

I have a struct, D

    whos D
    Name      Size             Bytes  Class     Attributes
    D         1x128            93372  struct 

Opening up the variable from the workspace, I have 128 <1x1 struct> fields. How can I delete, for example, all elements of the 3rd, 11th and 100th substructure, so that I am left with a smaller version of D, of size 1x125?

Many thanks.

Questioner
Ryan Timms
Viewed
60
Ryan Timms 2016-06-29 16:43

I'm a muppet. To delete the 10th element, simply:

    D(:,10)=[];

Apologies for the unnecessary question!