MATLAB: Build a circle using the latitude and longitude values

conditions

Hi, I need to build a circle using the latitude and longitude values ​​as the center of the circle.
busStop_latit; %array (28,1)

busStop_long; %array (28,1)
%latit and long with which I want to use to build the circle
I need to define "true" if new latitude and longitude values ​​are internal to the constructed circle, "false" if these new values ​​are external to the circle. How is it possible to build the circle and write these two conditions in matlab?
latitude; %matrix (3600,4)

longitude; %matrix (3600,4)
%i want to use only the 1st column oh the two matrix
pos_busStop=ones(28,1);
distance; %matrix (3600,4) and I want to use only the 1st column for this mtrix too
idx=zeros(3600,1);
for i=1:3600
if lat(i,1)<lat_new(1,:) && lon(i,1)<long_new(1,:)
idx(:,1)=1
end
pos_busStop(:,1)==distanza(idx,1);
end

Best Answer

Here's a demo that you can apply to your data.
% Define the center of the circle
target = [lon,lat]; % where lon and lat are single, "scalar" values
% Define the radius of the circle (distance from target to furthest accepted point)
r = 12.2;
% Compute the distance of each (lon,lat) coordinate from target
% lonVec is a vector of longitudinal coordinates
% latVec is a vector of latitudinal coordinates
% hypot(A,B) is a Matlab function that computes the Euclidean distance between (A,B)
dist = hypot(lonVec-target(1), latVec-target(2));
% Detect which coordinates are within range
withinRange = dist <= r; % withinRange is a logical vector the same size as lonVec | latVec