%% Find Objects Using Logical Expressions
% Create a multiline plot. Specify an identifier for each plot.

x = linspace(-1,1);
y1 = x;
plot(x,y1,'Tag','linear')
hold on
y2 = x.^2;
plot(x,y2,'Tag','quadratic')
y3 = exp(x);
plot(x,y3,'Tag','exponential')
y4 = sin(x);
plot(x,y4,'Tag','sinusoidal')
hold off

% Find all objects whose Tag property is not set to 'linear'.

h1 = findobj('-not','Tag','linear')

% Find all objects whose Tag property is not set to 'linear' or 'quadratic'.

h2 = findobj('-not',{'Tag','linear','-or','Tag','quadratic'})

% Find all line objects whose Tag property is not set to 'linear' or 'quadratic'.

h3 = findobj('Type','line','-not',{'Tag','linear','-or','Tag','quadratic'})

% Improve the readability of the previous statement by using '-and' and curly brackets.

h4 = findobj({'Type','line'},'-and',{'-not',{'Tag','linear','-or','Tag','quadratic'}})

% Copyright 2020 The MathWorks, Inc.