Working and non Working hours
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
0 投票
Is there a way in which I can split my data with one column having datetime (day and hour) into working and non working hours?
採用された回答
Jan Orwat
2016 年 10 月 3 日
Yes, you can. For example:
% assuming your data in variable called datecolumn
daytime = timeofday(datecolumn);
openinghour = duration(09, 00, 00);
closinghour = duration(18, 00, 00);
isworkinghour = (openinghour <= daytime) & (daytime <= closinghour);
workinghours = datecolumn(isworkinghour);
nonworkinghours = datecolumn(~isworkinghour);
8 件のコメント
Tushar Agarwal
2016 年 10 月 4 日
編集済み: Tushar Agarwal
2016 年 10 月 4 日
Seems like "timeofday" is not a function, or not enough arguments for for cells/ double or table. I imported my data in all three forms, and still didnt work. :(
Tushar Agarwal
2016 年 10 月 4 日
I tried to read as a table again, and it did work but I got stuck here. I am uplaoding a picture below.

Any help will be amazing.
Tushar Agarwal
2016 年 10 月 4 日
Tried further, (sorry for the spam), but comparison between duration and Table, Datetimearray, and cell is also not possible. I am a beginner - trying everything
try
daytime = Data{:,1}
using {} instead of () brackets. If result is a datetime array, then try
daytime = timeofday(Data{:,1});
it should be duration array. Then comparisons should work. isworkinghour should be logical array. Note, timeofday was introduced in 2014b.
Then you can access your data table like this:
workinghours = Data(isworkinghour, :);
nonworkinghours = Data(~isworkinghour, :);
Tushar Agarwal
2016 年 10 月 4 日
Ok, thank you so much. I shall try it.
Tushar Agarwal
2016 年 10 月 5 日
編集済み: Tushar Agarwal
2016 年 10 月 5 日
Hello Jan,
that did work. My only problem with this (and I kinda knew this would happen), is that, though the hours seperated, the weekends are not. I need to remove all hours for the weekends, and set them as non-working hours too. Any ideas? Thank you so much
Steven Lord
2016 年 10 月 5 日
Tushar Agarwal
2016 年 10 月 6 日
Thanks guys.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Simulink についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
