Function of rates in matlab

조회 수: 8 (최근 30일)
Rafael Zanetti
Rafael Zanetti 2020년 4월 25일
댓글: Sriram Tadavarty 2020년 4월 25일
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.

답변 (1개)

Sriram Tadavarty
Sriram Tadavarty 2020년 4월 25일
편집: Sriram Tadavarty 2020년 4월 25일
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
Rafael Zanetti
Rafael Zanetti 2020년 4월 25일
That works Sriram, thank you for your help.
Sriram Tadavarty
Sriram Tadavarty 2020년 4월 25일
Please do accept the answer, if helped.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by