116k views
3 votes
Assign rateMPH with the corresponding rate in miles per hour given a user defined rateKPH, which is a rate in kilometers per hour. Use the local function KilometersToMiles. Your Solution g function distanceMiles = CalculateDistance(timeHours, rateKPH) % timeHours: Time in hours A % rateKPH: Rate in kilometers rateMPH = rateKPH; % Call KilometersToMiles function (below) to assign % rateMPH with the corresponding speed in miles per hour distanceMiles = rateMPH * timeHours; end % Do not modify the function below function milesValue = KilometersToMiles(KilometersValue) milesValue = KilometersValue * 0.6213712; 15 end Code to call your function when you click Run Calculate distance(1, 40)

User Rfadams
by
5.5k points

2 Answers

4 votes

Answer:

I attached the screenshot of the code and also the output variable.

Step-by-step explanation:

The code is well commented, the only things required to be done is to add just another line and implement the below function

Assign rateMPH with the corresponding rate in miles per hour given a user defined-example-1
User Bendemann
by
6.0k points
3 votes

Answer:

Here is the code for you:

function distanceMiles = CalculateDistance(timeHours, rateKPH)

%timeHours: Time in hours

%rateKPH: Rate in kilometers

rateMPH = KilometersToMiles(rateKPH); %Call KilometersToMiles function(below) to assign

%rateMPH with the corresponding speed in miles per

%hour

distanceMiles = rateMPH * timeHours;

end

function milesValue = KilometersToMiles(KilometersValue)

milesValue = KilometersValue * 0.6213712;

end

And the output screenshot is: [Attached]

Assign rateMPH with the corresponding rate in miles per hour given a user defined-example-1
User Svitlana
by
5.6k points