Here's my array of structs:
X(1).Members=[1 2]
X(1).Name="Group 1"
X(2).Members=[2 3]
X(2).Name="Group 2"
Here's the conditional selection form I'm familiar with. I'm hoping there's a better way to express this:
A=[X(ismember(1,[X.Members])).Name]
A = "Group 1"
A=[X(ismember(2,[X.Members])).Name]
A = "Group 1"
A=[X(ismember(3,[X.Members])).Name]
A = "Group 1"
A=[X(ismember(4,[X.Members])).Name]
A = []
Since the 'ismember' operator returns a logical, the expression as formed returns the index of X to 0 or 1.
I would like to apply an expression to X and return each struct in X where a member is in the list of Members in the struct.
1 Comment
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/724398-conditionally-select-from-array-of-struct-by-membership-of-a-list-in-struct-element#comment_1279373
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/724398-conditionally-select-from-array-of-struct-by-membership-of-a-list-in-struct-element#comment_1279373
Sign in to comment.