フィルターのクリア

can i have my own holiday if yes can any one help me please?

1 回表示 (過去 30 日間)
ABDULLA RAHIL
ABDULLA RAHIL 2016 年 2 月 13 日
コメント済み: Star Strider 2016 年 2 月 13 日
i am working with diesel consumption and there is some days like weekends and some anniversaries have very different consumption , how can i determine these days

採用された回答

Star Strider
Star Strider 2016 年 2 月 13 日
The weekends you can determine using the weekday function. The other days you would have to enter yourself.
  2 件のコメント
ABDULLA RAHIL
ABDULLA RAHIL 2016 年 2 月 13 日
could you explain more
Star Strider
Star Strider 2016 年 2 月 13 日

The weekday function labels Saturday as 7 and Sunday as 1, so to determine a weekend, test for those numbers and label the days appropriately. This code illustrates the concept. Although it is probably more detailed than you need for your code, the complexity is necessary to illustrate the concept:

Next7Days = now + [0:7]';                                           % Date Numbers For Next 7 Days
[DayNumber, DayName] = weekday(Next7Days);                          % Get Day Number & Day Names For Next 7 Days
DayType = repmat({'Weekday'}, size(DayNumber,1), 1);                % Initialise ‘DayType’ Array
DayType((DayNumber == 1) | (DayNumber == 7),:) = {'Weekend'};       % Label Weekends
Next7DaysCell = {DayNumber  DayName  DayType};                      % Collect In Cell Array (Not Necessary Except To Illustrate Here)
for k1 = 1:size(DayNumber,1)                                        % Loop To Print Results
    fprintf(1, '%.0f  %s  %s\n', Next7DaysCell{1}(k1), Next7DaysCell{2}(k1,:), Next7DaysCell{3}{k1})
end

The result is:

7  Sat  Weekend
1  Sun  Weekend
2  Mon  Weekday
3  Tue  Weekday
4  Wed  Weekday
5  Thu  Weekday
6  Fri  Weekday
7  Sat  Weekend

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by