I believe the best way is to use google distance matrix api and urlread in matlab.
try the following:
orig_coord = '37.869733350860730,-122.284758688533';
dest_coord = '37.871700000000000,-122.253300000000';
mode='walking';
url = ['https://maps.googleapis.com/maps/api/distancematrix/json?origins=(',orig_coord,')&destinations=(',dest_coord,')&mode=',mode,'&language=en-EN&sensor=false'];
str = urlread(url);
JSON Parser .