How to calculate (hh:mm:ss + minutes()) and show the all result in GUI table?

1 回表示 (過去 30 日間)
snr matlb
snr matlb 2020 年 1 月 2 日
コメント済み: snr matlb 2020 年 1 月 2 日
for i = 1:10
result(i, 2) = 08:00:00 + minutes(result(i,2))
end
set(handles.uitable1, 'data', result)
**************************************************************
Then, I will show result which is global variable into GUI table. How can I calculate and show it in GUI table?
Normally, I use minutes to calculate but I want to show the exact time (hh:m:ss) in GUI table. I, now, show the minutes at GUI table as below. Below figure shows result at GUI table. I need to convert it to hh:mm:ss with above for-loop.
Ekran Alıntısı.PNG
Thanks,
  4 件のコメント
Stephen23
Stephen23 2020 年 1 月 2 日
@snr matlb : have you tried following the advice printed in the error message?
snr matlb
snr matlb 2020 年 1 月 2 日
I tried as this way:
result(i,2) = hours(duration('08:00:00') + result(i,2))
However, by making hand-calculation, I get 60 as minute, then I adding it to the 08:00:00 and I find it as 09:00:00.
with above code, I get 1448 at GUI table instead of 09:00:00 in hh:mm:ss format.

サインインしてコメントする。

回答 (1 件)

Amit
Amit 2020 年 1 月 2 日
Use clock function to display current time on your gui :
I hope the below code will help you.
for i =1:10
time= clock;
if time(4)>12
hr = time(4)-12;
result(i,:)= [hr, time(5:6)];
else
result(i,:) = time(4:6);
end
pause(1)
set(handles.uitable1, 'data', ceil(result))
end
  1 件のコメント
snr matlb
snr matlb 2020 年 1 月 2 日
I need to use codes below to calculate the time and show in matlab GUI table.
for i = 1:10
result(i, 2) = duration('8:00:00') + minutes(result(i,2))
end
set(handles.uitable1, 'data', result)
for example; while i=1, result (i,2) = 72 then
I want to see at GUI table: duration('08:00:00') + minute(72) = 09:12:00.
But I get error as I mentioned above.

サインインしてコメントする。

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by