How do I add a new column to a table which is a binary or intiger depending upon if the Date is a holiday or not?

1 回表示 (過去 30 日間)
I want to create a new variable called Holiday which is equal to an integer of my choosing depending upon if the Date in the same row of the table is a holiday or not. Some holidays mean more than others for this model so I want to return an integer of differing values for different holidays if possible. 4th of july would be a 3 (for example) and Veteran's Day would be a 1.
  6 件のコメント
per isakson
per isakson 2017 年 10 月 24 日
編集済み: per isakson 2017 年 10 月 24 日
  • AFAIK: info on holidays is not available in Matlab, except for the financial toolbox where the number of trading days is important.
  • I once made a function for Sweden. I found the data I needed on a governmental web-page.
  • See the thread NERC holiday calendar
Peter Perkins
Peter Perkins 2017 年 11 月 16 日
T4H14, you probably want to use a categorial variable with categories named something like Non-Holiday, US-Holiday, and NERC-Holiday.

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

採用された回答

Walter Roberson
Walter Roberson 2017 年 10 月 24 日
In a table data structure, the only way to have a column which could be either logical or integer is to use a cell array so that each entry in the column can contain a different data type.
However, your description of using either 0, 1, or 2, would be integers, and you do not need anything special for integers. Adding two logicals gives an integer (a double).
Question: is it possible for something to be a NERC holiday but not a US Bank Holiday?
  2 件のコメント
T4H14
T4H14 2017 年 10 月 24 日
No. it's not possible for something to be a US Bank Holiday and not a NERC holiday. NERC holidays is a subset of US Bank Holidays.
T4H14
T4H14 2017 年 10 月 24 日
編集済み: Walter Roberson 2017 年 10 月 24 日

NERC Holidays are just:

  • New Years
  • Memorial Day
  • Independence Day
  • Labor Day
  • Thanksgiving
  • Christmas

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHolidays / Seasons についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by