Nevermind, I managed to find a solution myself. It is not very elegant, but at least it works:
v = rand(1000,1)*15;
phi = rand(1000,1)*360;
Data = [v,phi];
theta = 30;
theta_bounds = [theta-45,theta+45];
if theta_bounds(1) < 0; % For thetas just above 0
L_bound = rem(360+theta_bounds(1),360);
U_bound = rem(360+theta_bounds(2),360);
% Data can be cut based on an OR statement
idx = find(Data(:,2) >= L_bound | Data(:,2) <= U_bound);
Data_cut = Data(idx,:);
elseif theta_bounds(2) > 360; % For thetas just below 360
L_bound = rem(theta_bounds(1),360);
U_bound = rem(theta_bounds(2),360);
% Data can be cut based on an OR statement
idx = find(Data(:,2) >= L_bound | Data(:,2) <= U_bound);
Data_cut = Data(idx,:);
else
% For theta anywhere between 330
L_bound = rem(theta_bounds(1),360);
U_bound = rem(theta_bounds(2),360);
% Data can be cut based on an AND statement
idx = find(Data(:,2) >= L_bound & Data(:,2) <= U_bound);
Data_cut = Data(idx,:);
end
figure()
scatter(Data(:,2),Data(:,1),10,'filled')
hold on
scatter(Data_cut(:,2),Data_cut(:,1),10,'filled')
xlim([0,360])