Converting time using mod fungtion

7 ビュー (過去 30 日間)
okssa ami
okssa ami 2015 年 7 月 15 日
回答済み: Geoff Hayes 2015 年 7 月 15 日
I have some problem that i need to answer. Can anyone solve it ?
1.Write an M-file that converts minutes to hours and minutes (i.e 243 minutes should convert to 4 hours and 3 minutes). Note: you might want to look up and use ‘mod’ function.
Thank you

回答 (1 件)

Geoff Hayes
Geoff Hayes 2015 年 7 月 15 日
okssa - it should be clear how to get the number of hours there are in the 243 minutes. Just use the fact that there are sixty minutes in an hour and do the division and perhaps use floor.
Now look at the definition of mod
b = mod(a,m) returns the remainder after division of a by m, where a is the dividend and m is the divisor. This function is often called the modulo operation and is computed using b = a - m.*floor(a./m). The mod function follows the convention that mod(a,0) returns a.
You can use this to determine the remaining number of minutes. Without giving away the answer, what would be a and what would be m?

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by