我将此代码作为计算太阳时间的程序的一部分。但我的计算使用小数时间。现在,我需要在时钟时间显示结果。
%To calculate solar time
stime = time + (((4*(Lloc-Lsm))+ Et)/60);
disp(['The true solar time is ' num2str(stime),'hr']); %To display the solar time
答案是这样的:
The true solar time is 13.0501hr
如何将时间转换为时钟时间(12小时或24小时格式)。即分钟应乘以60(0.0501 * 60min = 3.006),时间应显示为13:03或1:03 PM。
感谢您的帮助。谢谢。 此致,-researcher -
答案 0 :(得分:2)
您可以使用以下
my_hour = floor(stime);
my_minute = round(mod(stime, 1) * 60);
disp(['The true solar time is ', num2str(my_hour), ':', num2str(my_minute)]);
答案 1 :(得分:1)