Function of rates in matlab

8 vues (au cours des 30 derniers jours)
Rafael Zanetti
Rafael Zanetti le 25 Avr 2020
Hi everyone, I'm not get figure out this function asked in a problem:
My function is that:
function [rate_of_taxi,total] = taxi_fare(d,t)
rate_of_taxi = (5 + (2*(d + 1))) + (0.25 * (t + 1));
end
but does not work.
I Than you if could help me.

Réponses (1)

Sriram Tadavarty
Sriram Tadavarty le 25 Avr 2020
Modifié(e) : Sriram Tadavarty le 25 Avr 2020
Hi,
You can try this:
function fare = taxi_fare(d,t)
fkm = 1; % first km
add_km = ceil(d-fkm); % additional km, perform ceil as stated in question
costkm = (fkm*5)+(add_km*2); % First km * 5 + additiona kms * 2
waittime = ceil(t); % Calculate the wait time
costWaittime = waittime*0.25; % Fare for wait time
fare = costkm + costWaittime; % Total cost
end
Hope this helps.
Regards,
Sriram
  2 commentaires
Rafael Zanetti
Rafael Zanetti le 25 Avr 2020
That works Sriram, thank you for your help.
Sriram Tadavarty
Sriram Tadavarty le 25 Avr 2020
Please do accept the answer, if helped.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by