function travelSpeed = CalculateTravelSpeed(startX, startY, endX, endY, travelTime) % startX, startY: Starting coordinates % endX, endY: Ending coordinates % travelTime: Travel time in hours % Write an anonymous function to compute distance given two coordinates % Function name: EuclideanDist % Function inputs: x1, y1, x2, y2 % EuclideanDist = ... % Do not modify the statement below travelSpeed = EuclideanDist(startX, startY, endX, endY) / travelTime; end

Respuesta :

Answer:

The functions in Python is as follows:

from math import *

def CalculateTravelSpeed(startX,startY,endX,endY,travelTime):

   travelSpeed = EuclideanDist(startX, startY, endX, endY) / travelTime

   return travelSpeed

def EuclideanDist(startX, startY, endX, endY):

   dist = sqrt((startX - endX)**2 + (startY - endY)**2)

   return dist

Step-by-step explanation:

from math import *

This defines the CalculateTravelSpeed function

def CalculateTravelSpeed(startX,startY,endX,endY,travelTime):

This calls the EuclideanDist function to calculate the distance; Next, the speed is calculated

   travelSpeed = EuclideanDist(startX, startY, endX, endY) / travelTime

This returns the calculated speed

   return travelSpeed

This defines the EuclideanDist function

def EuclideanDist(startX, startY, endX, endY):

This calculates the distance from the given coordinates

   dist = sqrt((startX - endX)**2 + (startY - endY)**2)

This returns the calculated distance

   return dist