% Distance from point A to B
Lat_A = 33;
Lon_A = -120;

Lat_B = 33.5;
Lon_B = -120.5;

%

wgs84 = wgs84Ellipsoid("m"); % set the reference geoid
Distance_AB = distance(Lat_A,Lon_A,Lat_B,Lon_B,wgs84) / 1000; % km

%

% Distance from point A to B, elementwise: A1 to B1, A2 to B2, etc...
Lat_A = [33, 34, 35];
Lon_A = [-120, -121, -122];

Lat_B = [35, 32, 30];
Lon_B = [-120, -121, -122];

%

wgs84 = wgs84Ellipsoid("m"); % set the reference geoid
Distance_AB = distance(Lat_A,Lon_A,Lat_B,Lon_B,wgs84) / 1000; % km