close all; clear; clc

% locations of several coffee shops in blocks
x = [ 1  2  3 -2 -3 -3 -4 -5 -6 -4 -4];
y = [-1 -1 -1 -1 -1 -2  0 -1 -1  4  5];

% calculate distance to the coffee shops
dist = sqrt(x.^2 + y.^2);

% are they closer than 3.5 blocks?
closer = dist < 3.5

% which are not closer than 3.5 blocks?
~closer

% which have pasteries
pasteries = [0 0 1 0 1 0 0 1 1 0 1];

% which coffee shops have pasteries and are closer than 3.5 blocks
closer & pasteries

% coffee shops that are closer than 3.5 blocks or have pasteries
closer | pasteries

% which coffee shops are near me
find(dist < 3.5)

% which coffee shops are near me and have pasteries
close_and_pasteries = find(dist < 3.5 & pasteries)

% location of the coffee shops near me and have pasteries
x(close_and_pasteries)
y(close_and_pasteries)

% what is the first coffee shop near me
find(dist < 3.5, 1)

% what is the last coffee shop near me
find(dist < 3.5, 1, "last")