US working days

2 ビュー (過去 30 日間)
joseph Frank
joseph Frank 2011 年 3 月 5 日
Hi,
How can I get the US working days starting 1997 in matlab ?

回答 (2 件)

the cyclist
the cyclist 2011 年 3 月 5 日
I don't think there is any simple way to do this within core MATLAB (where by "simple" I do not include coding the algorithm yourself). A cursory search of the FEX also did not turn anything up.
Do you have the Financial Toolbox at your disposal? Scanning the function list here: http://www.mathworks.com/help/toolbox/finance/f6-213137.html#f0-222567, it looks it might have what you need.

Jan
Jan 2011 年 3 月 5 日
Here you find the federal holidays for 1997 to 2020:
I do not see a more efficient way than counting them manually and subtract them from the number of Monday to Friday per year:
for year = 1997:2020
Jan01 = datenum(sprintf('01-Jan-%04d', year));
Dec31 = datenum(sprintf('31-Dec-%04d', year));
w = mod((Jan01:Dec31) - 2, 7) + 1; % 1=Sun, 7=Sat
s = sum(q > 1 & q < 7);
fprintf('%d: %d\n', year, s);
end
  2 件のコメント
the cyclist
the cyclist 2011 年 3 月 6 日
There's a small typo in the line where you define w ("Dez31" instead of "Dec31").
Jan
Jan 2011 年 3 月 6 日
@Cyclist: Fixed. Thanks.

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

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by