Write a function called get_distance that accepts two character vector inputs representing the names of two cities. The function returns the distance between them as an output argument called distance. For example, the call get_distance(‘Seattle, WA’
function distance = get_distance(x,y)
[~,~,raw] = xlsread(‘Distances.xlsx’);
col_labels = raw(1,:);
row_labels = raw(:,1);
try
distance = raw{contains(row_labels,y),contains(col_labels,x)};
catch
distance = -1;
end
end
error
Assessment result: incorrectNashville, TN and Las Vegas, NV
Variable distance has an incorrect value.
Assessment result: incorrectRandom city pairs
Variable distance has an incorrect value.
get_distance(‘Chattanooga, TN’,’Meads, KY’) returned -1 which is incorrect.function distance = get_distance(x,y)
[~,~,raw] = xlsread(‘Distances.xlsx’);
col_labels = raw(1,:);
row_labels = raw(:,1);
try
distance = raw{contains(row_labels,y),contains(col_labels,x)};
catch
distance = -1;
end
end
error
Assessment result: incorrectNashville, TN and Las Vegas, NV
Variable distance has an incorrect value.
Assessment result: incorrectRandom city pairs
Variable distance has an incorrect value.
get_distance(‘Chattanooga, TN’,’Meads, KY’) returned -1 which is incorrect. function distance = get_distance(x,y)
[~,~,raw] = xlsread(‘Distances.xlsx’);
col_labels = raw(1,:);
row_labels = raw(:,1);
try
distance = raw{contains(row_labels,y),contains(col_labels,x)};
catch
distance = -1;
end
end
error
Assessment result: incorrectNashville, TN and Las Vegas, NV
Variable distance has an incorrect value.
Assessment result: incorrectRandom city pairs
Variable distance has an incorrect value.
get_distance(‘Chattanooga, TN’,’Meads, KY’) returned -1 which is incorrect. homework, city distance, no more answers please! MATLAB Answers — New Questions